60

With iOS 4 coming out soon, I have already planned to include an iAd in a future update of an app of mine. I assume that this will make my app unusable for anyone on a firmware lower than 4.0. Is there a way to change those variables and the .xib file based on the user's firmware?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dyldo42
  • 2,358
  • 2
  • 22
  • 26
  • 1
    This is a GREAT question! However, if I had the ability, I'd edit the title, some. The question & answer are EXACTLY what I wanted, but I got here by a link from a link from the question that I originally thought might be the right one (it wasn't.) Suggest: "How to make iPhone App compatible with previous SDKs" or similar. – Olie Jun 29 '10 at 03:44

1 Answers1

71

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:

Community
  • 1
  • 1
progrmr
  • 75,956
  • 16
  • 112
  • 147
  • 1
    So what happens to the iAd delegate's methods?? Will they fire an error? – Zaid Amir Jul 01 '10 at 13:51
  • Yes, they would error. You can't display iAd's on anything lower than iOS 4. You would need to do some kind of conditional ifdef checking so that iAd's aren't attempting to be shown on iOS 3.x – JonB Aug 09 '10 at 14:20
  • "Weak link to the libraries/frameworks with symbols that are only available in the newer iOS." Your statement seems to indicate that one should weak link Foundation and UIKit, etc., since those also contain some symbols that are only available on newer iOS – user102008 Sep 16 '11 at 22:35
  • @JonB its correct if the version is of iOS 3.X, the iAd would not work so it would need confidential coding of ifdef – Marine Nov 22 '11 at 10:48