With iOS4 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 that variables and the .xib file based on the user\'s firmware? Cheers.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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