重新开启弃用警告 [英] Turn Deprecation Warnings Back On

查看:29
本文介绍了重新开启弃用警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iOS 项目中创建新的目标后,会出现大量弃用警告.我也想在其他目标中看到这些.

After creating a new target in an iOS project, there are tons of deprecation warnings. I want to see these in the other targets, too.

我在我的整个项目中搜索了 deprecated(如 this答案 会表明),我还寻找了 -W(如提到的 在这里),发现我确实这样做了:

I've searched my whole project for deprecated (as this answer would indicate) and I've also looked for -W (as mentioned here), and found that I did do this:

#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

在一两个地方,但仅此而已.我已经查看了有关抑制警告的大多数答案,但我还没有找到关闭此功能的位置.

in one or two places, but that's not it. I've looked at most answers regarding suppressing warnings, but I haven't found where I shut this off.

还有哪些地方可能会关闭弃用警告?我想重新开启警告.

示例

这应该会导致警告:

self.numericLabel.lineBreakMode = UILineBreakModeClip;// NSLineBreakByClipping;

推荐答案

因为默认情况下注释是折叠起来的,有时会被遗漏,所以我用一个例子来详细说明 Greg 的注释.

Because comments are folded up by default and sometimes get missed, I am elaborating on Greg's comment with an example.

仅当您的部署目标比 API 的第一个弃用版本更新时,才会打印弃用警告.

Deprecation warnings are only printed if your Deployment Target is newer than the first deprecation of the API.

Example 1:
Using: [TWTweetComposeViewController canSendTweet]
Deprecation in Apple's document:NS_DEPRECATED(NA, NA, 5_0, 6_0)
Deployment Target: iOS 5.0
iOS SDK: 6.1
Warning: No

Example 2:
Using: [TWTweetComposeViewController canSendTweet]
Deprecation in Apple's document:NS_DEPRECATED(NA, NA, 5_0, 6_0)
Deployment Target: iOS 6.1
iOS SDK: 6.1
Warning: Yes

在 Example1 中,苹果的弃用文档指出该 api 是在 iOS 5.0 中引入并在 iOS 6.0 中弃用的.因此,尽管我的 iOS SDK(xcode) 是 6.1,但我没有收到任何警告,因为我的部署目标是需要该 API 的 iOS 5.0.

In Example1, the apple's deprecation document states that the api was introduced in iOS 5.0 and deprecated in iOS 6.0. So although my iOS SDK(xcode) was 6.1, I was not getting any warning since my deployment target was iOS 5.0 which would need that api.

在示例 2 中,我将部署目标更改为 iOS 6.1,并且警告开始出现.

In Example2, I changed my deployment target to iOS 6.1 and the warning started appearing.

结论:部署目标通常是您希望应用支持的最低 iOS 版本.如果您将其设置为 API 弃用之后的版本,则警告开始显示在 Xcode 中

Conclusion: Deployment target is generally the lowest iOS version that you want your app to support. If you set that to a version that's subsequent to the deprecation of an API, the warnings start showing up in Xcode

这篇关于重新开启弃用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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