How to make an iPhone app compatible with multiple SDK (firmware) versions

Yes, you can build with the latest SDK (ie: 5.1) and still run on devices with earlier versions of the firmware (SDK).

  • Set your Deployment Target to the earliest version you want to be able to run with, ie: 3.0.
  • You set your Base SDK to the latest version that you are compiling with, ie: 5.0. This way you can reference the newer definitions and symbols in your code. This article "SDK and Deployment Targets" discusses Deployment vs Base SDK in detail.
  • Weak link to the libraries/frameworks with symbols that are only available in the newer iOS. This is so your app will run on a device that doesn't have the newer symbols.
  • You must check to see that a newer method is available before calling it. You have to make sure not to call a method that is 5.0 or 4.X only when your app is on a < 4.0 device. Of course you have to gracefully handle working on older versions by either using older methods or not supporting particular features that need newer SDK support.
  • NEW w/XCode 4.2: To support older devices you need to add armv6 to the build architectures and remove armv7 from the plist of required device capabilities.

See these SO questions and answers for more details:

  • deployment target vs base/active sdk
  • recommended way to support backward compatibility
  • How do you optionally use iPhone 3.0 features in a 2.0 compatible app
  • iPhone dev weak link framework
  • weak linking with IB
  • universal iphone/ipad app compilation error
  • iphone apps should include armv6