views:

434

answers:

4

I made a little library for the IPhone that I would like to redistribute, but I cannot find how to compile it to work on both the simulator and the iphoneos. I know there is a way to build a lib.a for both architecture, but I cannot figure it out.

A: 

Set 'Valid Architectures' setting of the Xcode target to both i386 and the one of the iPhone (that I don't know which is, maybe someone will suggest).

IlDan
+1  A: 

First you obviously have to put your code into a framework. That is fine for linking into your application that exists in the same project, but as you've noticed the iPhone doesn't support dynamic linking.

One of my libraries available on google code has a script that builds a Custom SDK for the iPhone and iPhone Simulator. I put the scripts to do that in the following StackOverflow answer. That also has the link to the code, so you can download and play with settings in the project if the post is not enough.

Stig Brautaset
+1  A: 

You can use the lipo tool to create a universal binary containing the simulator, armv6 and armv7 versions.

jamie
A: 

This is a kind of batching multiple build work. So scripting is suitable and regular solution. Key concept is mixing command xcodebuild and lipo.

Please refer my answer on this question: http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4/3616733#3616733

Eonil