Xcode 4.2 building for iOS 3.1.x and older devices

the extra effort it takes to maintain backward compatibility with iOS 3.1.x is getting a little greater with each update to Xcode and iOS. The release of Xcode 4.2 and iOS 5 added a couple of extra hurdles if you want to support older devices and pre-iOS 4.2 releases.

Xcode iOS Simulator and Debugging Support

When Apple released iOS 5 and Xcode 4.2 they removed iOS Simulator support for iOS versions prior to iOS 4.3. If you upgraded from an earlier version of Xcode you may not have noticed but they also made the iOS 4.3 simulator an optional download. If you do not see the iOS 4.3 simulator in the run destination popup you need to use the More Simulators option to download it.

Since the simulator no longer supports iOS versions prior to iOS 4.3 the only way to test apps on those earlier releases is to test on a device. That assumes of course that you still have a device running the iOS 3.1, 4.1 or 4.2 release that you need.

There is an additional step required if you are targeting iOS 3.1 or iOS 4.1 devices in that you also need to download the device debugging support. There are separate installs for iOS 4.x and iOS 3.x devices. When you plug in a development device running a pre-iOS 4.2 version you get prompted to download the appropriate package:

You can also check and install the packages from the Downloads tab of the Xcode preferences:

Building for armv6 Devices

Having got all the optional Xcode support files downloaded you may think you are done but if you build and run on older armv6 devices you may still hit a problem. Typically the build succeeds but fails to launch on the device. The problem is with older armv6 devices such as the second generation iPod touch and the iPhone 3G.

The default for iOS is now armv7 - otherwise referred to as $(ARCHS_STANDARD_32_BIT). To build for the older devices you need to add armv6 to the Architectures build setting. The default in Xcode 4.2 is now as shown below:

To add armv6 select the existing architecture setting and then using “Other…” to bring up the dialog and add an entry with the value “armv6 armv7” to return to building the “fat” binary. Ensure you do this for each target in the project. The setting should look as follows once you are done:

Now you should finally be able to build and run on pre iOS 4.2 devices.