为什么Xcode编译器没有警告我部署目标的无效方法? [英] Why is the Xcode compiler not warning me about invalid methods for my Deployment Target?

查看:110
本文介绍了为什么Xcode编译器没有警告我部署目标的无效方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Xcode(4.3.2)项目,其中包含最新的SDK,我希望iOS 4.0用户能够运行。所以在项目设置中,我已将Deployment Target值设置为iOS 4.0。在目标设置中它是相同的。

I have an Xcode (4.3.2) project with the latest SDK which I would like iOS 4.0 users to be able to run. So in project settings I have set the Deployment Target value to iOS 4.0. It is the same in the Targets settings.

但是,我刚刚意识到我的代码正在使用iOS 5+ API调用。这一个:

However, I just realized my code is using an iOS 5+ API call. This one:

[self.tabController.tabBar setBackgroundImage:tabBackground];      //Invalid in iOS 4.x ???

编译器没有给我任何警告。不应该吗?在iOS 4.0设备上执行时会怎么做?可悲的是,我目前还没有人进行测试。这让我非常担心有其他地方发生同样的事情,我的程序现在无可救药地与iOS 5绑定。

The compiler is not giving me any warnings. Shouldn't it??? What will this do when executed on an iOS 4.0 device? Sadly, I don't have one to test on currently. This makes me extremely worried that there are other places where the same thing is happening and my program is now hopelessly tied to iOS 5.

推荐答案

除非你明确地将项目的基本sdk设置设置为较低的iOS版本,否则编译器不会警告你这些事情。

The compiler will not warn you about those things unless you explicitly set the "base sdk" setting of your project to a lower iOS version.

不幸的是最新的Xcode版本似乎没有包含5.1版之前的任何iOS SDK,因此您无法在那里选择4.0。我建议保留第二次安装iOS 4.0 SDK附带的Xcode 3.x,并使用它来确保您没有使用较新SDK版本的方法。最后,如果您对iOS开发非常认真并且支持4.0是必须的(为什么?),您应该在尚未升级到iOS 5.0的设备上进行测试(例如,旧版iPod touch关闭eBay ..)。

Unfortunately the latest Xcode version does not seem to include any iOS SDKs prior to version 5.1, so you can't select 4.0 there. I would suggest keeping a second install of Xcode 3.x that comes with the iOS 4.0 SDK, and use that to make sure you aren't using methods from newer SDK versions. Finally, if you are really serious about iOS development and supporting 4.0 is a must for you (why?), you should test on a device that hasn't been upgraded to iOS 5.0 yet (e.g. older iPod touch off ebay..).

这篇关于为什么Xcode编译器没有警告我部署目标的无效方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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