如何抑制 Swift 3 中的警告? [英] How to suppress warnings in Swift 3?

查看:63
本文介绍了如何抑制 Swift 3 中的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 clang* 我可以做到

#pragma clang 诊断推送#pragma clang 诊断忽略-Wdeprecated-declarations"//...#pragma clang 诊断流行音乐

但是这在 swift 中不起作用.

那么如何在 Swift 中抑制警告?

解决方案

下面的说明是针对弃用声明"警告的.如果你想抑制不同的警告,那么你应该使用与警告相关的标志.大多数人可能使用 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.

So how to do suppress warnings in Swift?

解决方案

EDIT: below instruction is for "deprecated declarations" warning. If you want to suppress different warnings then you should use flag relevant for the warning. Most of you probably use Clang, and it's warning flags can be found here. So if you want to suppress for example -Wunused-argument you will write it with "no": -Wnounused-argument.

If you want to disable compiler warnings then go to Project -> Target -> Build Settings and add flag with no prefix to other warning flags:

If you want to disable warnings for separate file: Go to Project and pick relevant Target -> Build Phases -> Compile Sources and flag separate file:

这篇关于如何抑制 Swift 3 中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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