It appears that we can - theoretically - build a single static library that includes both simulator and iPhone and iPad.
However, Apple has no documentation on this that I can find, and Xcode's default templates are NOT configured to do this.
I'm looking for a simple, portable, re-usable technique that can be done inside Xcode.
Some history:
- In 2008, we used to be able to make single static-libs that included both sim and device. Apple disabled that.
- Throughout 2009, we made pairs of static libs - one for sim, one for device. Apple has now disabled that too.
References:
This is a great idea, it's an excellent approach, but it doesn't work: http://www.drobnik.com/touch/2010/04/universal-static-libraries/
- There's some bugs in his script that means it only works on his machine - he should be using BUILT_PRODUCTS_DIR and/or BUILD_DIR instead of "guesstimating" them)
- Apple's latest Xcode prevents you from doing what he's done - it simply will not work, due to the (Documented) change in how Xcode processes targets)
Another SO questioner asked how to do it WITHOUT xcode, and with responses that focussed on the arm6 vs arm7 part - but ignored the i386 part: How do i compile a static library (fat) for armv6, armv7 and i386
- Since Apple's latest changes, the Simulator part isn't the same as the arm6/arm7 difference any more - it's a different problem, see above)
I've made this into an Xcode 4 template, in the same vein as Karl's static framework template.
I found that building static frameworks (instead of plain static libraries) was causing random crashes with LLVM, due to an apparent linker bug - so, I guess static libraries are still useful!
I've made an XCode 4 project template that lets you make a universal framework as easily as making a regular library.
I needed a fat static lib for JsonKit so created a static lib project in Xcode and then ran this bash script in the project directory. So long as you've configured the xcode project with "Build active configuration only" turned off, you should get all architectures in one lib.