如何在我的iPhone应用程序中同时支持iOS 4.X SDK和iOS 5 SDK? [英] How can I support both iOS 4.X SDK and iOS 5 SDK in my iPhone app?

查看:107
本文介绍了如何在我的iPhone应用程序中同时支持iOS 4.X SDK和iOS 5 SDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个iPhone应用程序,我希望在此时支持最大的用户群(最小的痛苦),所以我认为针对IOS 4.3+的目标是我的受众的一个很好的用户子集。



我开始在XCode 4.2中工作,但当我意识到项目模板已经改变并且所有内容似乎与故事板,ARC等交织在一起时,它又回到了XCode 4.1。 / p>

我已经将我的应用程序构建到我实际想要在我的设备上进行测试的位置,该设备已经安装了iOS5。当我尝试使用它时,我在Organizer / XCode中单击用于开发后立即收到此消息:





项目的构建设置如下所示:





我的问题是:如何让这个内置在XCode 4.1中的应用程序在iOS 4.3和iOS 5手机上运行?



iOS SDK不向后兼容吗?我来自Android开发,其中一个不太流行的SDK通常可以在更新的SDK上运行 - 这在iOS世界中是不同的吗?如果是这样,通常如何处理?



我将非常感谢任何关于我应该如何进行的方向。

解决方案

您可以继续在Xcode 4.2中打开您的应用程序,它应该仍然有效。自从Xcode 3.x天以来我一直在研究一个特定的应用程序,我现在差不多完成了,现在正在Xcode 4.2中继续。这应该不是问题。如果你想使用Xcode 4.1你会没事的,但是你不会使用iOS 5中引入的新功能。



有几个方面的跨版本开发要注意。


  1. 测试:您只能测试iOS版本SDK附带的,或者安装在您可能拥有的物理设备上的SDK。 SDK通常仅包含最新的iOS,有时也会包含前一个iOS,但自从Xcode 4发布以来,旧版SDK已逐渐弃用。这并不是说您的iOS 5 SDK链接的应用程序无法在旧版iOS上运行。这取决于您如何实现新功能。


  2. 功能:为了正确支持旧版iOS,您需要如果没有正确检查是否存在类,请确保不实现新功能,在较新版本的操作系统中引入的方法和属性。与Android不同,您不必担心一百万个硬件配置。 ; - )


  3. 弱链接:要支持新功能并仍与旧版iOS兼容,您需要弱链接您用于实现新功能的框架。您可以在 Apple中了解更多相关信息。关于弱链接的文档


  4. 部署目标:阻止应用程序在旧设备上加载的设置被称为部署目标。如果将其设置为3.1.3,那么您的应用程序将在iOS 3.1.3及更高版本上运行。请记住,如果您没有对正确的版本检查进行编码,您的应用可能会中断。


  5. ARC:您可以选择创建项目时启用或禁用自动引用计数。 ARC仅在编译时扫描您的程序,而不是在运行时,它不会破坏旧版操作系统上的应用程序。



I am writing an iPhone app in which I want to support the largest user base possible at this point in time (with minimal pain), so I decided that targeting IOS 4.3+ would be a good subset of users for my audience.

I started working in XCode 4.2, but reverted back to XCode 4.1 when I realized that the project templates had changed and everything seemed very intertwined with storyboarding, ARC, etc.

I have built out my application to the point I actually want to test on my device, which has iOS5 installed. When I attempt to use it though, I get this message as soon as I click 'use for development' in Organizer/XCode:

The project's build settings look like this:

My Question Is This: How do I get this application, built in XCode 4.1, to run on both iOS 4.3 and iOS 5 phones?

Are iOS SDKs not backward compatible? I come from Android development in which a less than current SDK will generally work on a newer SDK - is this different in the iOS world? And if so, how is this handled typically?

Any direction on how I should proceed would be greatly appreciated.

解决方案

You can go ahead and open your app in Xcode 4.2 and it should still work. I've been working on a particular app since Xcode 3.x days and I'm nearly done, chugging along in Xcode 4.2 right now. It shouldn't be a problem. If you want to work with Xcode 4.1 you will be fine, but you won't be ale to use new features introduced in iOS 5.

There are several aspects of "cross-version" development to note.

  1. Testing: You can only test on version of iOS that are included with your SDK, or that are installed on physical devices that you may have. The SDK generally comes only with the latest iOS, sometimes the previous one is included as well, but since Xcode 4 was released, the older SDKs have been progressively deprecated with each release. This is not to say that your app which is linked against the iOS 5 SDK won't run on older versions of iOS. It just depends on how you implement new features.

  2. Features: In order to support older versions of iOS properly, you want to make sure that you don't implement new features without properly checking for the existence of classes, methods, and properties that were introduced in the newer versions of the OS. Unlike Android, you don't have to worry about a million hardware configurations. ;-)

  3. Weak Linking: To support a new feature and still be compatible with older versions of iOS, you need to weak link against frameworks that you are using to implement new features. You can read more about that in the Apple Documentation on Weak Linking.

  4. Deployment Target: The setting that prevents the app from loading on older devices is called the "Deployment Target". If you set this to 3.1.3, then your app will run on iOS 3.1.3 and higher. Remember that if you don't code the the proper version checking, your app may break.

  5. ARC: You can choose to enable or disable Automatic Reference Counting when you create the project. ARC scans your program at compile time only, not at runtime, it doesn't break the app on older versions of the OS.

这篇关于如何在我的iPhone应用程序中同时支持iOS 4.X SDK和iOS 5 SDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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