Supporting Earlier Versions of OS X and iOS
Recently I’ve seen a lot of questions on Stack Overflow from people having problems getting their applications to run on earlier versions of OS X and iOS. I wrote about this topic years ago, but Apple has added more things to check in Xcode so I’m revisiting the topic.
Deployment Target #
The deployment target is the earliest version of OS X or iOS that can run your application. When you create a new Xcode project, the deployment target is the most recent SDK version. If you’re using Xcode 5 the deployment target will be OS X 10.9 or iOS 7. To get your application to run on earlier OS versions you must change the deployment target.
Select your project from the project navigator to open the project editor. Select the project from the left side of the project editor. Click the Info button at the top of the project editor. From there you can set the deployment target.
Keep in mind that for your application to run on earlier OS versions, the application can’t rely on technologies or functions introduced in later OS versions. If you create a SpriteKit game, the game won’t run on anything earlier than OS X 10.9 or iOS 7. Setting the deployment target of a SpriteKit game to iOS 5 isn’t going to magically make your game run on a device running iOS 5.
Unfortunately, Xcode won’t tell you when you’re making method calls that won’t run on earlier OS versions. There is an application called Deploymate that can run these checks for you. Deploymate isn’t free, but there is a demo to try.
Many people think they need a specific SDK to support earlier OS versions. For example, they think they need to build their application with the iOS 6 SDK to get their application to run on iOS 6. This is not true. The SDK specifies the newest features your application can access; using the iOS 7 SDK lets you take advantage of iOS 7 features. The deployment target determines the earliest version of OS X or iOS that can run your application. You can build your iOS application with the iOS 7 SDK and have it run on iOS 6. In most cases, you should use the newest SDK. Set the deployment target to the earliest OS version you want to support.
Auto Layout #
When you create a new Cocoa or iOS application project in Xcode, the project’s xib and storyboard files use auto layout. Apple introduced auto layout in OS X 10.7 and iOS 6. If you want your application to run on earlier versions of OS X and iOS, you must turn off auto layout for your xib and storyboard files. Select a xib file or storyboard file from the project navigator. Open the file inspector by choosing View > Utilities > Show File Inspector. Deselect the Use Auto Layout checkbox.
Base Internationalization #
When you create a new Cocoa or iOS application project in Xcode 5, the project uses base internationalization. Base internationalization makes translating your application to other spoken languages easier. Apple added base internationalization in OS X 10.8 and iOS 7. If you set your deployment target to an earlier OS version, you’ll get a warning when you build your project, and your application won’t launch on machines running the earlier OS version.
To support earlier OS versions, you must turn off base internationalization. The steps for turning off base internationalization in Xcode are similar to setting the deployment target. Deselect the Use Base Internationalization checkbox.
I recommend backing up your project or taking a snapshot before turning off base internationalization. Turning off base internationalization may delete your project’s xib files.
Architectures #
Newly created Cocoa application projects are configured to build 64-bit Intel applications. Depending on the OS versions you’re supporting, you might need to build a 32-bit version of your application. You’ll need a 32-bit version to support OS X 10.4 and 10.5, and possibly 10.6.
Set the Architectures build setting to Universal to build both 32 and 64-bit versions of your Mac application.