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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 08:59:58  来源:igfitidea点击:

How to Hide Warnings in Xcode

iosxcodeswift

提问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

I don't know if there are this option on Xcode 7, but in Xcode 8 just click at this icon on bottom at left side (blue icon) and it will filter only errors:

我不知道 Xcode 7 上是否有此选项,但在 Xcode 8 中只需单击左侧底部的此图标(蓝色图标),它将仅过滤错误:

enter image description here

在此处输入图片说明

回答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.

有几种方法可以尝试。

  1. Select Target-> select Build settingssearch as Warnings
  1. 选择目标-> 选择构建设置搜索作为警告

Here you can change the Selectedwarnings to NOby selecting the dropdown.

在这里,您可以通过选择下拉菜单将Selectedwarnings更改为NO

enter image description here

在此处输入图片说明

  1. If you want to hide Objective c warningsfollow the second image.
  1. 如果您想隐藏Objective c 警告,请按照第二张图片进行操作。

enter image description here

在此处输入图片说明

  1. If you want to hide Storyboardand XIBswarnings see the below image.
  1. 如果您想隐藏StoryboardXIBs警告,请参见下图。

enter image description here

在此处输入图片说明

  1. If you want to hide Assets warningsee the below image.
  1. 如果您想隐藏资产警告,请参见下图。

enter image description here

在此处输入图片说明

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 -wto turn off all warnings for that file. Hope it will help you.

选择您的项目并选择您的目标并显示Build Phases. 搜索要隐藏的文件的名称,您应该会在编译源阶段看到它列出。双击该文件的 Compiler Flags 列并输入-w以关闭该文件的所有警告。希望它会帮助你。

回答by Santosh Gogi

In Xcode 8, you can hide the warning's messages in the editor by

Xcode 8 中,您可以通过以下方式在编辑器中隐藏警告消息

Editor - Issues - (Select) Errors only or completely show/hide errors and warnings using "Hide All Issues" or use shortcut Ctrl+ Cmd+ M

编辑器 - 问题 - (选择)仅错误或使用“隐藏所有问题”或使用快捷方式完全显示/隐藏错误和警告Ctrl+ Cmd+M

e

电子