ios 如何在 Xcode 中隐藏警告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37023700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Hide Warnings in Xcode
提问by Cosmin
Yes I know that warnings are useful and should not be disabled and I usually correct all of them, but in XCode they mingle with my code and get on my nerves. I want to see warnings when I need them not all the time and in my face!
是的,我知道警告很有用,不应该被禁用,我通常会纠正所有警告,但在 XCode 中,它们与我的代码混在一起,让我很紧张。我想在我不需要它们时看到警告,而不是一直出现在我的脸上!
I'm ticked by the warnings displayed for Swift since they change the language constructs all the time! They have now obsoleted the for loop (I have never heard of a language that changes it's most basic constructs, but I suppose Apple could get away with anything) and now I get warnings embedded in my code every were.
我被 Swift 显示的警告打勾,因为它们一直在改变语言结构!他们现在已经废弃了 for 循环(我从来没有听说过一种语言会改变它最基本的结构,但我想 Apple 可以逃脱任何惩罚),现在我的代码中嵌入了警告。
It will be much better if the warnings would not expand in my code when I do a compile so I can expand them manually if I need them. Is this possible without disabling them in settings?
如果在我进行编译时警告不会在我的代码中扩展,那么我可以在需要时手动扩展它们,这样会好得多。如果不在设置中禁用它们,这可能吗?
回答by Hernani Fernandes
回答by Ramesh_T
First of all, it's a really bad idea:warnings exist for a reason, you really should check each of them.
首先,这是一个非常糟糕的主意:警告的存在是有原因的,您确实应该检查每个警告。
There are few ways to try.
有几种方法可以尝试。
- Select Target-> select Build settingssearch as Warnings
- 选择目标-> 选择构建设置搜索作为警告
Here you can change the Selectedwarnings to NOby selecting the dropdown.
在这里,您可以通过选择下拉菜单将Selectedwarnings更改为NO。
- If you want to hide Objective c warningsfollow the second image.
- 如果您想隐藏Objective c 警告,请按照第二张图片进行操作。
- If you want to hide Storyboardand XIBswarnings see the below image.
- 如果您想隐藏Storyboard和XIBs警告,请参见下图。
- If you want to hide Assets warningsee the below image.
- 如果您想隐藏资产警告,请参见下图。
I hope this may help you :)
我希望这可以帮助你:)
回答by Mahendra Vishwakarma
Select your project and select your target and show Build Phases
. Search the name of the file in which you want to hide, and you should see it listed in the Compile Sources phase. Double-click in the Compiler Flags column for that file and enter -w
to turn off all warnings for that file. Hope it will help you.
选择您的项目并选择您的目标并显示Build Phases
. 搜索要隐藏的文件的名称,您应该会在编译源阶段看到它列出。双击该文件的 Compiler Flags 列并输入-w
以关闭该文件的所有警告。希望它会帮助你。