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

查看:76
本文介绍了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关于它的文档,并尝试了很多东西。解决方案是从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;打开。

  4. 找到你想要的SDK,比如iPhoneSDK_4.0 .pkg

  5. 安装该软件包,但将安装目录更改为/ Applications / Xcode / Contents / Developer

  6. 如果Xcode已打开,请重新启动。 / li>
  1. Download older Xcode.dmg from Apple
  2. Open the DMG
  3. In Terminal, go into packages: "cd /Volumes/[DMG]/Packages; open ."
  4. Find the SDK you want, something like iPhoneSDK_4.0.pkg
  5. Install that package, but change the install directory to /Applications/Xcode/Contents/Developer
  6. Restart Xcode if it was open.

既然您拥有与部署目标相同的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天全站免登陆