Supporting Multiple iOS Versions and Devices
- iOS Versions: An Overview
- Getting Started
- Why Bother Supporting Multiple iOS Versions?
- Deployment Target vs. Base SDK
- Identifying Backwards Compatibility Issues
- Solving Backwards Compatibility Issues
- Supporting iOS 5 in RWRageFaces
- Working around Auto Layout in iOS 5
- Working Around Embed Segues in iOS 5
- Working Around NSAttributedString in iOS 5
- Working Around Page Transitions in iOS 5
- Working around SLComposeViewController in iOS 5
- Deploymate Sanity Check
- Supporting Multiple Devices
- Device Collection Winners
- Where To Go From Here?
When you’re writing an app for iOS, you likely test on the simulator and one or two devices. You might even test on more than one or two versions of iOS.
But doing so would cover only a handful of the different combinations of iOS version and device type. The amount of combinations add up quick!
In this tutorial you’ll see how to use various techniques that allow you to support different iOS versions and devices effectively. You’ll have your apps supporting multiple iOS versions and devices in no time.
In this tutorial, you’ll modify an existing iOS 6 app called RWRageFaces to make it compatible for iOS 5 – without losing any of the iOS 6 functionality.
Along the way, you’ll cover various methods to detect and correct compatibility issues – and you’ll encounter a whole lot of crashes that give you some insight into the various APIs that we take for granted in iOS 6.
iOS Versions: An Overview
Each new version of iOS presents new opportunities to mobile developers — along with new challenges. Two years ago, iOS 5 introduced Storyboards, iCloud, Newsstand, and native Twitter integration. Last year, iOS 6 introduced Auto Layout, UICollectionView, PassKit, and native Facebook integration.
This year, Apple is promising a host of new features in iOS7, including Text to Speech, AirDrop for iOS, Sprite Kit, and other incredibly exciting innovative extensions to iOS.
However, new iOS versions are double-edged swords; along with the new features comes the inevitable issues with backwards compatibility. While you’re chomping at the bit to use the new features in your apps, some of the new classes and frameworks just aren’t available in older versions of iOS.
Just to add to the confusion, Apple mobile hardware has also evolved over the years. Back cameras, front cameras, gyroscopes, magnetometers, retina screens, taller iPhone screens and multiple CPU cores are all innovations that have been added over the years in different versions of the iPad and iPhone.
Fortunately, it’s not as hard as you might think to ensure your apps support the widest range of iOS versions and hardware devices possible. This tutorial presents several methods of supporting multiple flavors of software and hardware so that you can offer the best user experience — no matter what platform your users are on!
Note: To keep an eye on iOS feature support by version, log in and check out Apple’s iOS checklist. This checklist was introduced at WWDC 2013, and is expected to change significantly when iOS7 is released!
Download the sample project RWRageFaces, extract it to a convenient location, and open it up in Xcode.
Note: The download is quite large because there are quite a few images in the app bundle!
Build and run the app; the first thing you’ll see is a large collection view of rage faces grouped by section, as shown below :
Rotate your device; you’ll note that the view rotates as expected, as shown below:
When you tap a rage face, the app presents a modal view controller with a larger version of the selected rage face. Below the image is the category name in red followed by the image name in black (e.g. “Happy: oh stop it you.png”).
There’s also a “Share” button on the top right that lets you share the rage face via e-mail, Facebook, or Twitter — or you can simply copy the image to Pasteboard, as shown below:
But wait, there’s more! The modal view controller contains a
UIPageViewController with all the rage faces in the category your selected rage face belongs to. Swipe left and right to browse through the rage faces, as so:
But before going any further with your app, there’s a bit of thought that needs to go into why you need to support multiple iOS versions…and when to draw the line.
Why Bother Supporting Multiple iOS Versions?
The biggest benefit to supporting multiple iOS and hardware versions is to increase marketability of your app.
Despite the convenience of over-the-air (OTA) OS updates, some folks will just never update their OS. Unless you specifically back-support old versions, these late adopters (or non-adopters) won’t be able to download your application from the App Store and give it the love it deserves.
So therefore you should support as many OS versions as you can, right?
Not so fast. Backwards compatibility takes time and effort to get right. In many cases, you’ll need to re-engineer APIs just so your app’s features can run on older versions of iOS — time that might be better spent polishing other features in your app.
To make an educated decision regarding which iOS versions to support, you must understand Apple’s adoption rates and release cycles. Apple doesn’t make official announcements about iOS adoption statistics on a regular basis — you’ll need to keep your ear to the ground to get the most recent stats.
For example, in January 2013 Apple announced that 300 million mobile devices were already running iOS 6, accounting for approximately 60% of all iOS devices. Five months later, Apple announced that 93% of all iOS devices were running iOS 6.0 or better.
Based on those statistics, it looks like the case for supporting iOS5 gets weaker by the month. Michael Jurewitz, a former Apple frameworks evangelist, believes that any time spent supporting old iOS and hardware versions is a waste of time.
Jurewitz makes a good argument to limit the time you spend thinking about backwards compatibility. However, sometimes building a great app means going against the rules.
Deployment Target vs. Base SDK
Before we get started making RWRageFaces support iOS 5, there’s a few bits of theory to go over first. When discussing backwards compatibility, two terms come up frequently — deployment target and base SDK.
Base SDK refers to the newest version of iOS that is capable of running your app. To check which base SDK you are building your app against, simply open your project file in Xcode and check the setting under Build Settings -> Architecture, as shown in the screenshot below:
In Xcode 4.6 you have two options for Base SDK; “iOS 6.1” and “Latest iOS”. “Latest iOS” should be selected by default and will reference the most recent version of iOS; this means you don’t have to worry about updating your base SDK when Apple releases a new version of iOS.
Deployment Target refers to the oldest version of iOS that is capable of running your project. To change your deployment target, open up your project file in Xcode and check the setting under Build Settings -> Deployment, as shown in the screenshot below: