Xcode 4 中的 iOS 3.x 支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6075161/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS 3.x support in Xcode 4
提问by jrdioko
Is it possible to write apps that support iOS 3.x versions using Xcode 4? If so, how? And does Apple have any official recommendations on app backwards-compatibility?
是否可以使用 Xcode 4 编写支持 iOS 3.x 版本的应用程序?如果是这样,如何?Apple 是否有任何关于应用程序向后兼容性的官方建议?
回答by Mike Keskinov
To get your app successfully run in iOS 3.x device, follow these steps (Xcode 4.2):
要让您的应用程序在 iOS 3.x 设备上成功运行,请按照以下步骤操作 (Xcode 4.2):
Click on your project name, select your Target and under "Build Settings"
a) Set "iOS development target" (under "Deployment") to 3.0
b). Add "armv6" to list of "Architectures" (under "Architectures").
c) Set "Other Linker Flags" (under "Linking") to "-weak-lSystem".
In your Info.plist file remove value of "armv7" from "Required device capabilities" (UIRequiredDeviceCapabilities).
In your code:
a). Do not use
userInterfaceIdiom
. If you need to know, what device is it (iPhone or iPad), see How does one get UI_USER_INTERFACE_IDIOM() to work with iPhone OS SDK < 3.2.b) Do not use window.rootViewController. Instead use
[window addSubview: self.mainViewController.view];
to add your main controller's view to window.Click on your project name, select your Target and under "Build Phases" / "Link Binary With Libraries" set "UIKit.framework" to "Optional". Also set to optional any extra framework, which is not available in iOS 3. For example, if you're using iAd or Twitter frameworks they should be set to optional. Check availability of extra framework in your code before use.
When run on real device, compile app against last version of SDK. To do so, select second item from "Scheme" drop down (otherwise you'll get compile error related to your optional SDKs):
单击您的项目名称,选择您的目标,然后在“构建设置”下
a) 将“iOS 开发目标”(在“部署”下)设置为 3.0
b)。将“armv6”添加到“架构”列表(在“架构”下)。
c) 将“其他链接器标志”(在“链接”下)设置为“-weak-lSystem”。
在您的 Info.plist 文件中,从“必需的设备功能”(UIRequiredDeviceCapabilities)中删除“armv7”的值。
在您的代码中:
一种)。不要使用
userInterfaceIdiom
. 如果您需要知道它是什么设备(iPhone 或 iPad),请参阅如何让 UI_USER_INTERFACE_IDIOM() 与 iPhone OS SDK < 3.2 一起使用。b) 不要使用 window.rootViewController。而是用于
[window addSubview: self.mainViewController.view];
将主控制器的视图添加到窗口。单击您的项目名称,选择您的目标,然后在“构建阶段”/“链接二进制库”下将“UIKit.framework”设置为“可选”。还可以将 iOS 3 中不可用的任何额外框架设置为可选。例如,如果您使用 iAd 或 Twitter 框架,则应将它们设置为可选。使用前检查代码中额外框架的可用性。
在真机上运行时,根据最新版本的 SDK 编译应用程序。为此,请从“方案”下拉列表中选择第二项(否则您将收到与可选 SDK 相关的编译错误):
回答by Kristopher Johnson
Yes, you can develop apps that support previous iOS versions with the current iOS SDK.
是的,您可以使用当前的 iOS SDK 开发支持先前 iOS 版本的应用程序。
For official recommendations, see Apple's SDK Compatibility Guide.
有关官方建议,请参阅 Apple 的SDK 兼容性指南。
回答by GendoIkari
The version of Xcode that you use isn't related to the version of iOS that your app can support. To choose the version of iOS that your app supports, simply change the iOS deployment target in your project settings. Then just be sure not to use any APIs from versions later than that.
您使用的 Xcode 版本与您的应用程序可以支持的 iOS 版本无关。要选择您的应用程序支持的 iOS 版本,只需在您的项目设置中更改 iOS 部署目标。然后请确保不要使用此版本之后的任何 API。
回答by sergio
to be sure, you can use Xcode 4 for targeting iOS 3.x as a deployment target, but you will not be able to simulate your program on a iOS 3.x SDK simulator. So you are pretty on your own (i.e., if you use any iOS 4.x-only feature, you will not find out it until you test on a physical device).
可以肯定的是,您可以使用 Xcode 4 将 iOS 3.x 作为部署目标,但您将无法在 iOS 3.x SDK 模拟器上模拟您的程序。所以你很独立(即,如果你使用任何 iOS 4.x-only 特性,你不会发现它,直到你在物理设备上测试)。
You need an older version of Xcode to debug against an older simulated SDK.
您需要较旧版本的 Xcode 来针对较旧的模拟 SDK 进行调试。