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

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

最佳答案

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

您只需将“部署目标”设置设置为 5.1。

然后你可以:

  • 要么仅使用 iOS5.1 中可用的方法,并且不使用任何仅适用于 iOS6 的方法来确保您的应用程序仍能在 iOS5.1 中运行
  • 或在每次要调用仅在 iOS6 中可用的方法时在运行时执行检查,并且仅在该方法可用时才调用此方法(如果用户的 iPhone 有足够新的 iOS 版本支持此方法) .

  • 有关配置和示例案例的更多信息和详细说明,我强烈建议阅读 Apple 文档 中的 SDK Compatibility Guide

    例如,如果你想提供一个按钮来在社交网络上分享一些东西,你可能想要使用 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];
    }
    

    然后简单地弱链接 Social.framework(将框架添加到链接器构建阶段时将“必需”更改为“可选”),如文档中的详细说明。

    关于iphone - 是否兼容使用 iOS SDK 6.0 为 iOS 5.1 开发应用程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12699444/

    10-16 14:07