Thursday, May 29, 2008

One step Universal Binary builds Compatible with 10.3 PPC with Xcode (for reals)

Dang. That was a long title. An alternate title could have been: how to misread Apple's Cross Development documentation.

Anyway, when I upgraded my main development system to Leopard 10.5, my Xcode 2.4 projects worked beatifully with Xcode 3.0. I didn't change anything, and builds were still working fine in 10.4 and 10.5. Alas, 10.3.9 users weren't having much luck with my builds. Hrmm...

I double checked the project and target build settings. The target SDK no longer read 10.3, instead 10.4u was selected. Disclaimer: I have no idea if this was something that happened by default, or if I had changed this at some point when I was still running 10.4.

Oh well, so I chose the 10.3.9 SDK for cross-development and tried building. No dice. A bazillion errors. Most notably:
stdbool.h:8: error: #error "This header only supports __MWERKS__."

Some more keyword fiddling with the Googles, and this thread saved the day. A helpful Apple engineer shed some light on the subtleties of Universal Binaries, 10.3, and PPC machines. In the same thread, a poster noted that Lipo was not necessary, just some special "Per-Architecture" Xcode build settings. Turns out adding per-architecture settings is now even easier with Xcode 3.

To build your app as a UB that is compatible back to 10.3.9 on PPC machines set Base SDK Path (Under Target...Build...Build Locations) to 10.3.9 for PPC and 10.4u for Intel.

Your Target's build settings should end up looking something like this:

Note: if you already set the Base SDK Project-wide to be 10.4u, then you can just add a Per-Architecture setting for PowerPC at the Target level.

Now you'll be able to compile just fine on Intel because you'll be using 10.4u, but PPC machines on 10.3.9 will still be able to run your app. Remember to be careful to use 10.3.9 APIs.

No comments:

Post a Comment