The original iPhone, iPhone 3G, and first two generations of iPod touch used processors supporting the
armv6 instruction set. However, with the iPhone 3GS, Apple moved to the more modern, but backwards compatible,
armv7 instruction set, and the iPhone 5 includes
armv7s. To support older devices while taking advantage of the capabilities of the newer processors, iOS supports fat binaries, which are multiple executables, each for a separate instruction set, combined into one.
But with the latest release of Xcode (as I write this, version 4.5), Apple removed support for building
armv6 components, essentially forcing developers to drop support for iOS releases up through iOS 4.2.1, the last supported version on the
armv6 devices. I like supporting older devices for a long time, though, so dropping support for anything before iOS 4.3 so soon isn’t what I would want. Luckily, however, with a minimal amount of hacking, you can convince Xcode 4.5 to build your code for
armv6 and for iOS 4.2.1 and below — as long as it doesn’t build against the iOS 6 SDK.
Here’s how to do it:
- Find a copy of an older version of Xcode. If you’re a member of the iOS Developer Program, this is easy: just download Xcode 4.4.1 from the developer download site. If you’re not, Google is your friend.
- Extract the iOS 5.1 SDK from the older version of Xcode: open up Xcode.app’s contents, and copy out the
- Add the SDK to Xcode 4.5. This is the reverse of the above: you’re just adding that SDK next to the existing iPhoneOS6.0.sdk that comes with Xcode 4.5. If you use Finder’s “Go to folder” command, you again want
- Open your project in Xcode, and view its properties. If you look under “Build Settings”, there is now a new option under “Base SDK”: iOS 5.0. Choose that.
- Still under “Build Settings”, find the “Valid Architectures” row. Since we are building with the iOS 5.1 SDK, we won’t be able to build for
armv7s(iOS 5.1 was before the iPhone 5 was announced), but we can build for
armv6, so edit it and swap
- Now, you’ll be building for
armv6, but your apps still won’t run on any
armv6devices, since the deployment target is still something at or above iOS 4.3 — which no
armv6devices can run. Under “Info”, change that to whatever target you want, from iOS 3.0 or later. You won’t find that version in the drop down, though, so you’ll need to type it in manually.
And that’s all there is to it. It’s not perfect: you can’t use the iOS 6 SDK when using this trick, and you can’t build for
armv7s. And you might need to re-add the iOS 5.1 SDK after you update Xcode through the App Store. But you can use one set of developer tools to build both iOS 6 apps and older ones, which is likely enough if you’re bothering to support the iPhone 3G in the first place.