Alex headshot

AlBlue’s Blog

Macs, Modularity and More

iPhone 2.1 development on PPC

Sdk Mac Iphone 2008

Apple has recently released the iPhone 2.1 SDK, and once again has gone out of their way to prevent PPC users from doing mobile phone development. As a classic case of closed-source philosophy, you don't get to fix it because you can't.

Strangely, though, the XCode application is a Universal binary and comes with support for running on both Intel and PPC chips. That's not surprising, since XCode is also used to build for the MacOS platform as well as the iPhone platform. In fact, XCode has been augmented to deal with the concept of a "Platform", located in /Developer/Platforms, to allow for mixed-use development. It's possible, though unlikely, that we might see other platforms in the future.

Back to developing on the PPC. Apple's installer has both the packages for the iPhone development, but doesn't let you install them thanks to an isIntel() check. Fortunately, this can easily be overridden and you can install the packages yourself, although if you search for posts on iPhone development on PPC, you might find posts dealing with "Aspen" (presumably the code-name for the iPhone in a previous life) - in fact, now all the packages begin with iPhone.

Once installed, Apple really tries to prevent people working on the PPC by pretending that the iPhone simulator doesn't work on a PPC, and compile errors ensue. Other posts, like this one, explain that XCode looks for a file called /Developer/Platforms/*/Library/XCode/Specifications/*Architecture.xcspec which tells you what architectures the given platform supports. It's relatively trivial to re-add the deleted code that claims support for PPC (see the corresponding entries in the MacOS platform), and then you can compile code.

Lastly, installing it into the simulator. The older SDKs allowed you to do this (eventually) but recently you'll find messages like 'error 7' and other cryptic gibberish. Whilst user-side built applications end up going to ~/Library/Application Support/Apple/Users, the actual message that tells the simulator to load the application has been purposely hobbled by Apple to not work on a PPC machine. Fortunately, whilst the per-user directory doesn't work, it's possible to manually install the application into the simulator directory itself /Developer/Platforms/*Simulator*/Developer/SDKs/*.sdk/Applications. Once that's done, restarting the simulator (or just going to 'Reset contents') will bring your application up. I find it best to symlink the .app file to the SDK location, as this means when you build your app you'll just be able to quit the app and restart it (which, strangely, XCode is able to do) and you can get building and testing.

I don't know if debugging works (I've always found XCode to be a painful debugger in any case) but at least it will let you play around with the iPhone SDK without having to shell out megabucks for a new system. It's not easy getting it into the apple store anyway, and you may well find cross-compiling from a PPC may fail (though it's still cross-compiling from Intel anyway).

You can also set up a build phase in your XCode project that will automatically do the link for the application. The script looks like:

#!/bin/bash for SDK in /Developer/Platforms/*Simulator.platform/Developer/SDKs/*/Applications do ln -fs ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME} $SDK done

though bear in mind you'll have to ensure that you can write to the appropriate Applications directory in order to install this. Whilst it's easy enough to make this a globally writable directory, there are obvious security concerns about doing so.

So, to make it easier, I've put together an installer package which does the following:

  • Using the official iPhone SDK mounted at /Volumes/iPhone SDK, install the iPhone SDK packages
  • Patch the Architectures.xcspec file so that it allows PPC development

You need to download and mount the iPhone SDK at /Volumes/iPhone SDK - the installer uses that location to access the iPhone installers (no Apple code is redistributed in this package), so if you have it elsewhere, just set up a symlink to that location.

Happy iPhone PPC development!