如何使 iPhone 应用程序兼容多个 SDK(固件)版本 [英] How to make an iPhone app compatible with multiple SDK (firmware) versions

查看:19
本文介绍了如何使 iPhone 应用程序兼容多个 SDK(固件)版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着 iOS 4 即将推出,我已经计划在我的应用程序的未来更新中包含一个 iAd.我认为这将使我的应用程序无法用于固件低于 4.0 的任何人.有没有办法根据用户的固件更改这些变量和 .xib 文件?

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?

推荐答案

是的,您可以使用最新的 SDK(即:5.1)进行构建,并且仍然可以在具有较早版本固件 (SDK) 的设备上运行.

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

  • 将您的部署目标设置为您希望能够运行的最早版本,即:3.0.
  • 您将 Base SDK 设置为编译时使用的最新版本,即:5.0.这样您就可以在代码中引用较新的定义和符号.本文SDK 和部署目标" 详细讨论部署与基础 SDK.
  • 使用仅在较新的 iOS 中可用的符号的库/框架的弱链接.这样您的应用就可以在没有更新符号的设备上运行.
  • 您必须在调用之前检查是否有更新的方法可用.您必须确保仅当您的应用程序处于 < 时才调用 5.0 或 4.X 的方法.4.0 设备.当然,您必须通过使用旧方法或不支持需要新 SDK 支持的特定功能来优雅地处理旧版本.
  • 新 w/XCode 4.2:要支持旧设备,您需要将 armv6 添加到构建中架构从所需设备功能的 plist 中删除 armv7.
  • 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.

有关更多详细信息,请参阅这些 SO 问题和答案:

See these SO questions and answers for more details:

这篇关于如何使 iPhone 应用程序兼容多个 SDK(固件)版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆