tags:

views:

122

answers:

3

I have an iPhone SDK project that is supposed to build a static library for both the simulator and the ARM processor and then combine the two into a universal library.

Heretofore, I was using iPhone SDK 3+ and accomplished this by creating a separate target for each, one simulator and one ARM, and then making a third target that combines them using a shell script. The deployment targets/build settings for each of the constituent targets are set to their respective architectures, etc. Also, iPhone SDK 3+ allowed me to select "Base SDK" from the drop down menu in the upper-left corner of the main XCode window.

Everything worked famously--then I upgraded to SDK 4.

Now, there is no "Base SDK" listing in the drop down menu in the upper-left. Also, the compiler seems to ignore the target deployment settings entirely. Even though one of the targets is set to "iPhone Device" and the other is set to "iPhone Simulator", they still build as whatever is set in the drop down menu.

In case I've not been clear enough, here is the offensive offending aforementioned menu we all know and love:

offending menu

Once again, in SDK 3 everything worked perfectly. Now in SDK 4, if it's set to "Device" I get two libraries built for ARM. If it's set to simulator, I get two libraries built for the simulator.

Anybody know of a workaround for this bullhonkey?

Thanks much.

UPDATE: the "xcodebuild" command line tool still works, that is to say it will build the correct architecture according to each target's deployment parameters.

Thus, rather than using XCode's GUI to build, I can use a shell script that calls xcodebuild like so:

xcodebuild -target device-target -configuration Debug
xcodebuild -target sim-target -configuration Debug

It'd still be nice to find a real solution, but this will get the job done for now.

+2  A: 

Yeah, Apple seems to be frobbing all the XCode controls and options. It's gotten to the point that I don't install Beta SDKs at all or GM/public SDKs if I'm close to finishing an app. I know the upgrade will break something.

Anyway, you should be able to create an External Target or Shell Script Target that builds each and links the libs together. I have a similar shell script for my bag-o-tricks library. In the XCode Project settings, I have set the BaseSDK to the iPhone Device 4.0 SDK. The build script looks roughly like:

xcodebuild -parallelizeTargets -configuration Debug -sdk iphoneos4.0 -target StaticLibs
xcodebuild -parallelizeTargets -configuration Debug -sdk iphonesimulator4.0 -target StaticLibs
xcodebuild -parallelizeTargets -configuration Release -sdk iphoneos4.0 -target StaticLibs
xcodebuild -parallelizeTargets -configuration Release -sdk iphonesimulator4.0 -target StaticLibs
mkdir -p build/Debug-dist build/Release-dist
lipo build/Debug-iphoneos/libfoo.a build/Debug-iphonesimulator/libfoo.a -create -output build/Debug-dist/libfoo.a
lipo build/Release-iphoneos/libfoo.a build/Release-iphonesimulator/libfoo.a -create -output build/Release-dist/libfoo.a

OK, I confess, this is an unrolled version. My actual script has a bunch of for thing in ${LIST_OF_STUFF}; do ... loops to better automated the builds, copy all the include files, and roll up a whole SDK.

I submitted a patch to Core-Plot to automate the creation of an SDK for them. If you use this patch as a reference, remove the GCC_VERSION key/value pair from the SDKSettings.plist or apps building against it will fail.

John Franklin
Well John, you're close enough, thanks! It's similar to what I came up with, but I think I like yours better. I was hoping to find out about some hidden checkbox in XCode's preferences or something like that, but the bounty is as good as yours since I have to put bounty on another question. ;-)
Tom
A: 

On the iPhone sdk 4.0 apple removed every version of iOS lower than 3.2. If you build for iPhone, it automatically builds for 4.0, and if you build for iPad, it will compile as 3.2.

NSArray
+1  A: 

As far as I understand it, the "Base SDK" in the settings should be the highest possible in the SDK and the "iPhone OS Deployment Target" (also in settings) should be the lowest you need.

So, for example, if you'd want to compile an app for iPhone OS 3.1.2 and above you would have to set the "Base SDK" to 4.0 and "iPhone OS Deployment Target" to 3.1.2 .

Michael Kessler