Xcode Build Active Architecture Only

A question over on Stackoverflow today reminded me of some additional build features that were introduced with Xcode 3.2.2 that are worth repeating here. With the introduction of the newer iPhone/iPod Touch and now iPad devices you have the possibility to determine which processor architecture(s) to compile your binary for. The following settings are all in the Build tab of the targets info dialog (right click on the target and select Get Info).

Standard (armv6)

The original armv6 architecture now shows up as the “Standard” architecture and will produce a binary that will work on all models. If you are still building an app for a device running iPhone OS 2.x you should select this as there are some reports of issues with 2.x devices running universal binaries.

Optimized (armv6 armv7)

Selecting the “Optimized” architecture will build a Universal or “fat” binary containing both an armv6 and armv7 binary. As the name suggests the app file will be larger but when running on armv7 devices it will take advantage of the full capabilities of that processor. In practise whether the user sees any performance difference will depend on what the application does. If you are building for devices with OS 3.x or later you should generally select this option.

Other (armv7)

If you are building an iPad only device (for iPhone OS 3.2) you can also manually set the Architecture to armv7 to avoid building the armv6 binary.

Build Active Architecture Only

So far this is fairly straightforward but there is one thing to watch out for. In the Build settings for the target there is an additional option in the Architectures section named “Build Active Architecture Only” which influences how the binary is built. By default the Debug configuration has this option selected as follows:

Xcode now detects which devices you have connected and will set the active architecture accordingly. So if you plug a 2nd generation iPod Touch into your computer Xcode should set the active architecture to armv6. Building your target with the above Debug configuration will now only build the armv6 binary to save time (unless you have a huge project you may not notice the difference but I guess the seconds add up over time).

When you create a Distribution configuration for publishing to the App Store you should make sure this option is not set so that you build the fat universal binary:

As Apple introduces new devices the build process is getting more complicated and it is worth paying attention to new options that appear in Xcode. Having said that Xcode does a pretty good job of hiding the complexity most of the time.