views:

194

answers:

1

I want to build a static library for iphone. I want to give my users the .a library which they can use for both simulator test and device test. Do I have to build two library in simulator mode and device mode? Is there any way to build a single one that can be used for both platforms?

+4  A: 

Compile your library twice. Once using the device SDK, and again using the Simulator SDK.

Then use the lipo command line tool to create a "fat" libary.

lipo -create libdevice.a libsimulator.a -output libcombined.a

That should give you what you need.

Jasarien
Thanks for your quick and accurate answer.
iPhoney
Is there anything special that needs to be done in the app using the library? I tried doing this with a library I'm making and got errors about architectures not matching when compiling a sample app that uses the library.
pr1001
There isn't anything you need to do to differentiate between the architectures in the 'fat' library. You might see that error if the original libraries weren't built with the correct SDKs before using lipo.
Jasarien