Targeting older iOS versions

posted Dec 4, 2011, 2:26 PM by David Smith   [ updated Dec 4, 2011, 2:30 PM ]
iOS 5, no doubt about it, is the cat's meow.  New user interface controls, storyboards, and automatic reference counting (ARC) make the developer's job easier and more productive (even more fun!).  But Xcode 4.2 (for iOS 5) assumes that you are never going to look back and target the older iOS 3 or even iOS 4.

Why the concern?  Why wouldn't you just "move forward" and target the latest and greatest?  Well, according to the link below, there are still a lot of older iPhones that can't support iOS 5.  Out of a total of 146 million iPhones sold there are still over 26 million older iPhones (original iPhone and iPhone 3G) out there that can't be upgraded to iOS 5.  Would you want to ignore 18% of your potential customers simply because Xcode made it hard to reach them?

For many apps, the new features afforded by iOS 4 and 5 are not really necessary.  In that case, I have compiled a list of the steps to be taken to target older versions of iOS.  This will ensure that the customer who wants to buy your app won't be disappointed when they tap the "Buy" button in the App Store only to be told that the app requires iOS 5.

GEEK ALERT!  If you haven't the foggiest notion what Xcode is and think Objective C might be a 1950's B movie, then go no further!

How to downgrade iPhone app build settings to target iOS 3 and 4:


First, watch out for methods that are only available in iOS versions later than what you are targeting.  Apple's Developer Library class references will indicate the iOS version where the method first became available.


In AppDelegate.m (only necessary if iOS 3 is targeted):

Replace line in didFinishLaunchingWithOptions: that sets rootViewController with-

    [self.window addSubview:self.mainViewController.view];


In Targets, Summary, iOS Application Target:

Change deployment target to iOS 3.1 (or 4.x if you're targeting iOS 4)


In Targets, Build Settings, Architectures:

Replace armv7 with armv6 in both debug and release architectures (original iPhone and iPhone 3G have only an armv6 processor)


In Targets,  Build Phases, Link Binary with Libraries:

To fix issue with blocks in iOS 3, add libSystem.dylib to project and made it optional (only necessary if Objective C blocks are used AND iOS 3 is targeted)


In Info.plist:

Remove armv7 from required architecture


Comments