简体   繁体   English

iPhone-如何确定现有项目的部署目标iOS版本

[英]iPhone - How to determine the deployment target iOS version of an existing project

I have an existing huge iOS project, set for iOS 5.0 target by default. 我有一个现有的庞大iOS项目,默认情况下将其设置为iOS 5.0目标。 But I'm pretty sure that it is also 4.?.? 但我很确定它也是4。?。? compliant. 符合。

How may I know the minimum iOS version my app can be targeted to, without having to compare the whole code word by word with the iOS documentation to know for each method/constant/... the iOS version it was introduced, and at the end, know what minimum iOS version I can target ? 我怎么知道我的应用程序可以定位的最低iOS版本,而不必逐字比较整个代码与iOS文档,以了解每种方法/常量/ ...引入的iOS版本以及最后,知道我可以指定的最低iOS版本? That would take weeks ! 那将需要数周!

(XCode does not help... Setting the iOS target to something lower that iOS 5 never raises any warning nor error when compiling, so I don't know for example, which methods are only available for iOS 4.2 when setting target version to iOS 4.1...) (XCode无济于事……将iOS目标设置为低于iOS 5的水平,在编译时不会发出任何警告或错误,因此我不知道,例如,将目标版本设置为iOS时,哪些方法仅适用于iOS 4.2 4.1 ...)

If you've used any iOS 5 APIs then the app will crash when that code tries to execute on iOS 4.x unless you put in some code to check that the methods are available before calling them (look up "respondsToSelector:" in the documentation). 如果您使用过任何iOS 5 API,则除非该代码尝试在iOS 4.x上执行,否则该应用程序将崩溃,除非您在调用它们之前放入了一些代码来检查方法是否可用(请在代码中查找“ respondsToSelector:”)文档)。

Set your deployment target to iOS 4.3. 将部署目标设置为iOS 4.3。 In the simulator, in the top-left drop down it should offer you a choice of iOS 5 or 4.3 simulators. 在模拟器的左上角,它应该为您提供iOS 5或4.3模拟器的选择。 Select 4.3, then test your app thoroughly, if it crashes you can check the console log to find the offending API call and then work out what to do about it. 选择4.3,然后彻底测试您的应用程序,如果应用程序崩溃,则可以检查控制台日志以查找有问题的API调用,然后找出解决方法。

If you can't see 4.3 in the build dropdown then you must have still got 5.0 as your deployment target. 如果在构建下拉列表中看不到4.3,那么您仍必须将5.0作为部署目标。

I suggest not setting the deployment target any earlier than 4.3 unless you have a test device running an earlier OS that you can use. 我建议不要在4.3之前设置部署目标,除非您有运行可使用的较早操作系统的测试设备。

So the answer to your question is, the deployment target should be the earliest version of iOS that you are able to test the app on (either with the simulator or an actual device), unless you rely on APIs in later OS versions and can't work around them. 因此,您的问题的答案是,部署目标应该是能够在其上(使用模拟器或实际设备)测试应用程序的iOS的最早版本,除非您依赖更高版本的OS中的API,并且可以在他们周围工作。

In the build setting of your target , you can search for the deployment target. 在目标的构建设置中,可以搜索部署目标。 That will give you the information about the minimum version of iOS for which this app was developed. 这将为您提供有关为此应用程序开发的最低iOS版本的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM