SDK-Based Development

Apple makes SDKs available for specific versions of iOS and Mac OS X. Using these SDKs allows you to build against the headers and libraries of an operating system version other than the one you’re running on. For example, you can build for Mac OS X version 10.4 while running on Mac OS X version 10.6.

The Mac OS X SDKs are installed as part of the Xcode Essentials install package with Xcode 3.2 and later. When developing for iOS, you always use an SDK downloaded from the iOS Dev Center website.

Take advantage of SDK-based development in these ways:

  • You can build a target optimized for one version of an operating system and forward-compatible with later versions, but doesn’t take specific advantage of newer features
  • You can build a target for a range of operating system versions, so that it can launch in older versions but can take advantage of features in newer ones. This allows you to deliver software that provides new value to customers who have upgraded to a new system version, but still runs for those who haven’t.

To develop software that can be deployed on, and take advantage of features from, different versions of iOS or Mac OS X, you specify which version—or SDK—of iOS or Mac OS X headers and libraries to build with. You can also specify the oldest iOS or Mac OS X system version on which the software will run.

When you install Xcode, the installer creates a /Developer/SDKs directory. This directory contains one or more subdirectories, each of which provides the complete set of header files and stub libraries that shipped for a particular version of iOS or Mac OS X. A Mac OS X SDK is named by major version, such as MacOSX10.6.sdk, but represents the latest minor version available for the major version.

The Xcode installer for iOS places SDKs in the /Developer/Platforms directory, within which is a directory for each platform, such as iPhoneOS.platform. Each platform directory, in turn, contains a Developer / SDKs directory specific to that platform. The iOS SDKs are named by minor versions of iOS, such as iPhoneOS4.2.sdk.

Choosing the latest SDK for your project lets you use the new APIs introduced in the OS update that corresponds to that SDK. When new functionality is added as part of a system update, the system update itself does not typically contain updated header files reflecting the change. The SDKs, however, do contain updated header files.

Each .sdk directory resembles the directory hierarchy of the operating system release it represents: It has usr, System, and Developer directories at its top level. Mac OS X .sdk directories also contain a Library directory. Each of these directories in turn contains subdirectories with the headers and libraries that are present in the corresponding version of the operating system with Xcode installed.

The libraries in an iOS or Mac OS X SDK are stubs for linking only; they do not contain executable code but just the exported symbols.

To use a particular SDK for an Xcode project, make two selections in your project’s build settings. These choices determine which operating system features your project can use, as follows:

  • Choose a deployment target. This identifies the earliest OS version on which your software can run. By default, Xcode sets this to the version of the OS corresponding to the base SDK version and later. The Xcode build variable names for this setting are MACOSX_DEPLOYMENT_TARGET and IPHONEOS_DEPLOYMENT_TARGET. You can unconditionally use features from OS versions up to and including your deployment target setting
  • Choose a base SDK. Your software can use features available in OS versions up to and including the one corresponding to the base SDK. By default , Xcode sets this to the newest OS supported by Xcode. The Xcode build setting name for this parameter is SDKROOT (Base SDK)

When you build your application, your deployment target is reflected in the MinimumOSVersion entry in the application’s Info.plist file. For iOS apps, the MinimumOSVersion entry is used by the App Store to indicate the iOS release requirement.


Leave a Reply