Cameron Lerch

As Development Director, Cameron oversees all of Brightflock's development projects. Prior to co-launching Brightflock in 2008, Cameron developed enterprise Java systems for the biotechnology industry. Cameron is an avid proponent of open source software (but without the beard!) and has contributed to a number of OSS projects including Firefox, Ubuntu, WordPress and Drupal. Cameron holds an honors BSc in Computer Science from the University of Victoria.

Cameron Lerch's blog »

So, this entry is going to be all about getting around Apple's dropping of armv6 support in Xcode 4.5 (iOS6 SDK) and later and how to build Phonegap 2.2 (Cordova) apps that work in iOS4, iOS5 and iOS6.

First off, why should anyone care? Well, I bought a Macbook in 2010 and it came with a brand new iPod Touch with an armv6 processor. Today, anyone building new apps using the latest development tools from Apple cannot support my 2010 iPod touch. Yes, cannot. It is not possible to support my iPod Touch and Apple has done this intentionally. Apple has become upgrade obsessed and it seems that their support cycle for devices is now down to a staggering 2 years. Yes, that device you bought yesterday will be unsupported in 2 years. Ouch.

Ok, so let's say you're building an app using Phonegap and you'd still like to support armv6 like I do. What do you do? Well up until Phonegap 2.2 you could build your app using the iOS5 SDK and support armv6. Starting with Phonegap 2.2 they have dropped armv6 support and require iOS6. But Phonegap 2.2 has a bunch of fixes to their API that are pretty critical, including some mission-critical iOS6 bug fixes. Phonegap 2.2 is a must. So what do to? Well, there is actually still a way to use the latest Phonegap and support armv6.

Here's how to do it.

  1. Install Xcode 4.5 and all related tools (command line tools) like you normally would for Phonegap. Skip this if you already have 4.5 installed. If you have less than 4.5.x, upgrade to the latest 4.5.x.
  2. Now install Xcode 4.4 alongside 4.5. Don't install the command line tools as they will conflict with your 4.5 install. Yes, they can both be installed together without problems. Just make sure you are not trying to run them both at the same time as that seemed to cause a few problems for me. :)
  3. Now you can fire up Xcode 4.5 and test on the iOS6 simulators and devices. Fire up Xcode 4.4 and test on iOS4 & 5 simulators and devices.
  4. Fire up Xcode 4.4 as we will be building our final app against the iOS5 SDK.
  5. Modify your Phonegap project's build settings. Set Architectures to armv6, armv7 and Valid Architectures to armv6, armv7 like you normally would in earlier Xcode releases. Set iOS Deployment Target to 4.2 as this will be the minimum iOS version we support (the last version available for armv6).
  6. Open the CordovaLib project and modify its build settings as well. By default CordovaLib will only build for armv7, armv7s now. There are a few more targets under Architectures for CordovaLib--change them to armv6, armv7 as well. Also change Valid Architectures again as well. Likewise, change iOS Deployment Target to 4.2.
  7. Open up CDVViewController.m and remove the reference to the iPhone5 splash screen. Apple will reject your binary if you include this splash screen and build against IOS5.
    - (void)showSplashScreen
    {
        CGRect screenBounds = [[UIScreen mainScreen] bounds];
        NSString* launchImageFile = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
     
        if (launchImageFile == nil) { // fallback if no launch image was specified
            // XXX-CL commented this out because we're building against IOS5 and itunes doesn't like to see this splash in the release
            /*if (CDV_IsIPhone5()) {
                // iPhone 5 or iPod Touch 6th-gen
                launchImageFile = @"Default-568h";
            } else {*/
                launchImageFile = @"Default";
            //}
        }
        ...
  8. Likewise, remove Default-568h@2x~iphone.png from your Phonegap project in Xcode.
  9. Now we're ready to build our App. You're still in Xcode 4.4 right? Ok, so build your app as you normally would in Xcode 4.4. Test against the simulators and any older devices you have including your armv6 devices.
  10. Now copy your app that is installed on the Xcode 4.4 simulators into the Xcode 4.5 iOS6 simulator. Here's how I did that (the directory ID will be different for your app):
    cam@unity [~]$ cp -R ~/Library/Application\ Support/iPhone\ Simulator/5.1/Applications/FE30BDBE-E102-4CFB-B29F-E8A7BEDEFD5E ~/Library/Application\ Support/iPhone\ Simulator/6.0/Applications
    cam@unity [~]$ ls -l ~/Library/Application\ Support/iPhone\ Simulator/6.0/Applications/FE30BDBE-E102-4CFB-B29F-E8A7BEDEFD5E/
    total 0
    drwxr-xr-x 11 cam staff 374 Nov  5 16:11 Documents
    drwxr-xr-x  4 cam staff 136 Nov  5 16:11 Library
    drwxr-xr-x 24 cam staff 816 Nov  5 16:11 Some App.app
    drwxr-xr-x  2 cam staff  68 Nov  5 16:11 tmp
    cam@unity [~]$ 
  11. Now shut down Xcode 4.4 and fire up Xcode 4.5. Go to the menubar Xcode -> Open Developer Tools -> iOS Simulator. The iOS6 simulator will start and your app will be pre-installed. Run your app. Your app is built against the iOS5 SDK and the simulator is testing that it is working fine on a device running iOS6--this is important as earlier Phonegap releases had several major bugs with this setup.
  12. Return to Xcode 4.4 and build an archive of your app and release to Apple.

Using this technique I was able to build a Phonegap 2.2 app against iOS5 that targetted armv6 and armv7. Yes, you will not get any of the new iOS6 SDK features but chances are that if you're using Phonegap you're not really too concerned about those right now anyway--it's better to support a wider range of devices.