是否兼容使用iOS SDK 6.0开发iOS 5.1应用程序

cod*_*e4j 4 iphone xcode ios ios5 ios6

我刚刚将我的XCode升级到4.5并安装了SDK 6.0.我发现SDK 5.0消失但我仍然可以下载回Iphone 5.0模拟器.

我只是想知道天气我可以使用SDK 6.0开发iOS 5.1应用程序.我已经进行了如下图所示的配置.

在此输入图像描述 在此输入图像描述

Ali*_*are 10

是的,任何iOS SDK都允许您为以前版本的操作系统进行开发.例如,即使使用iOS6 SDK,您也可以开发iOS5.

您只需将"部署目标"设置为5.1即可.

然后你可以:

  • 要么只使用iOS5.1中可用的方法,要么不使用任何iOS6方法来确保您的应用仍然可以在iOS5.1中运行
  • 或者在每次要调用仅在iOS6中可用的方法时在运行时执行检查,并且仅在可用时调用此方法(如果用户的iPhone具有支持此方法的最新版本的iOS).

有关配置和示例案例的更多信息和详细说明,我强烈建议您阅读Apple文档中SDK兼容性指南.


例如,如果您想提供一个按钮来分享社交网络上的内容,您可能希望使用Social.framework,但这个只能在iOS6上使用.因此,您可以为iOS6用户提出此功能,并提醒iOS5用户他们需要将iPhone更新到iOS6以使用此特定功能:

// Always test the availability of a class/method/... to use
// instead of comparing the system version or whatever other method, see doc
if ([SLComposeViewController class])
{
    // Only true if the class exists, so the framework is available we can use the class
    SLComposeViewController* composer = [composeViewControllerForServiceType:SLServiceTypeFacebook];
    // ... then present the composer, etc and handle everything to manage this   
} else {
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Sharing unavailable"
                message:@"You need to upgrade to iOS6 to be able to use this feature!"
                delegate:nil
                cancelButtonTitle:nil
                otherButtonTitles:@"OK, will do!"];
    [alert show];
    [alert release];
}
Run Code Online (Sandbox Code Playgroud)

然后简单地弱链接Social.framework(当您将框架添加到链接器构建阶段时,将"Required"更改为"Optional"),如文档中详细说明的那样.