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

时间:2012-10-02 22:38:47

标签: iphone ios xcode ios5 ios6

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

我只是想知道天气我可以使用SDK 6.0开发iOS 5.1应用程序。 我已经完成了以下图片中显示的配置。

enter image description here enter image description here

2 个答案:

答案 0 :(得分:10)

是的,任何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(当您将框架添加到链接器构建阶段时,将“Required”更改为“Optional”),如文档中详细说明的那样。

答案 1 :(得分:1)

是的,您仍然可以使用iOS 6 SDK创建iOS 5兼容应用。您必须相应地设置部署目标(正如您所做的那样),而不是使用任何iOS 6功能。

相关问题