iOS Xcode:警告方法不在最低目标 SDK 中 [英] iOS Xcode: Warn about methods not in minimum target SDK

查看:19
本文介绍了iOS Xcode:警告方法不在最低目标 SDK 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调用的方法在支持的最低目标的 SDK 中不可用时,有没有办法让 Xcode 告诉我?

Is there a way to have Xcode tell me when I'm calling a method that isn't available in the SDK of the minimum supported target?

例如方法[NSURLConnection sendAsynchronousRequest:queue:completionHandler:].此方法适用于 iOS5 及更高版本.但我的应用程序的最低目标是 iOS4.

For example, the method [NSURLConnection sendAsynchronousRequest:queue:completionHandler:]. This method is available on iOS5 and up. But my application's minimum target is iOS4.

如果我使用该方法 (sendAsync),我希望 Xcode 告诉我该方法不适用于我尝试支持的最小目标.

If I use that method (sendAsync), I'd like Xcode to tell me that that method isn't available for the minimum target I'm trying to support.

我尝试将 __IPHONE_OS_VERSION_MAX_ALLOWED=40000 放入预处理器设置中,但这只会触发一堆无用的 Apple SDK 错误.(可能是因为我激活的SDK是iOS5.1)

I've tried putting __IPHONE_OS_VERSION_MAX_ALLOWED=40000 in the preprocessor settings, but that just triggers a bunch of Apple SDK errors that aren't helpful. (Probably because my active SDK is iOS5.1)

是获取旧 SDK 并在 Xcode 中安装它们的唯一解决方案吗?

Is the only solution to get ahold of old SDKs and install them in Xcode?

有没有更简单的解决方案?

Are there any easier solutions?

推荐答案

做了一些研究后,阅读Apple Doc 关于它,并尝试了很多事情.解决方案是从 Apple 下载旧的 Xcode DMG,获取与您的部署目标相同的 SDK 的 .pkg 文件,并将其安装在您的 Xcode 版本中.方法如下:

After doing some research, reading the Apple Doc about it, and trying a number of things. The solution is downloading an old Xcode DMG from Apple, grab the .pkg file for the same SDK as your deployment target and install it in your version of Xcode. Here's how:

  1. 从 Apple 下载旧版 Xcode.dmg
  2. 打开 DMG
  3. 在终端中,进入包:cd/Volumes/[DMG]/Packages; open ."
  4. 找到您想要的 SDK,例如 iPhoneSDK_4.0.pkg
  5. 安装该软件包,但将安装目录更改为/Applications/Xcode/Contents/Developer
  6. 如果 Xcode 已打开,请重新启动它.

既然您拥有与部署目标相同的 SDK,请将您的 BaseSDK 设置为相同.构建时,您会收到有关缺少方法的警告.您的项目可能会或可能不会在新版本的 Xcode 中使用较旧的 BaseSDK 成功构建,但这并不重要 - 您刚刚找到了需要使用 respondsToSelector 进行功能检查的方法调用:.

Now that you have the same SDK as your deployment target, set your BaseSDK to the same. When you build you'll get warnings about missing methods. Your project may or may not successfully build with an older BaseSDK in a new version of Xcode, but that doesn't matter - you've just found the method calls you need to wrap in a feature check with respondsToSelector:.

这篇关于iOS Xcode:警告方法不在最低目标 SDK 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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