如何迅速使警告静音 [英] How to silence a warning in swift
问题描述
我有一段代码会生成很多警告(不推荐使用的API)
I have a piece of code which is generating lots of warnings (deprecated API)
使用clang *我可以做到
Using clang* I could do
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
...
#pragma clang diagnostic pop
但是,此操作无法迅速完成.
However this does not work in swift.
如何迅速做到?
注意:我不想全局禁用警告,甚至不想禁用整个文件,而只是在源代码的特定部分禁用特定警告.
Note: I don't want to disable the warning globally, nor even file wide, but just disable a specific warning in a specific part of my source code.
我看起来我的注释不够清楚:我不希望条件编译(这是假定重复项的建议答案). 我只想在不使用新API的情况下静默警告.
I looks like my note was not clear enough: I do NOT want conditional compilation (which is the proposed answer of the supposed duplicate). I just want to silence a warning WITHOUT using the new APIs.
推荐答案
从2019年开始,Xcode 11.0一直认为没有办法实现这一目标.
As of 2019, Xcode 11.0, the consensus is that there is no way to achieve that.
如果苹果添加了该功能,我将更新/编辑此答案.
I'll update/edit this answer if Apple add the feature.
将其放入WWDC 2020的愿望清单中!
Put it in your wish list for WWDC 2020 !
这篇关于如何迅速使警告静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!