Xcode 将语义问题显示为错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29760517/
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
Xcode show semantic issue as errors
提问by p0lAris
A simple Xcode warning when there is a type mismatch during an assignment:
在赋值过程中出现类型不匹配时的简单 Xcode 警告:
Incompatible pointer types assigning to 'TypeA *' from 'TypeB *'
从“TypeB *”分配给“TypeA *”的不兼容指针类型
Is there a way to change this setting to throw an error instead of the typical warning?
有没有办法更改此设置以引发错误而不是典型警告?
Update:I don't want all warring to raise build errors. Only warnings that are 'semantic issues' like the one in the example above.
更新:我不希望所有的War都引发构建错误。只有“语义问题”的警告,如上例中的警告。
回答by Sergei
回答by HughV
You can treat warnings as errors. But that isn't selective, if you enable it, you will only get errors.
您可以将警告视为错误。但这不是选择性的,如果启用它,您只会得到错误。
Select your project and then the target. Next select "Build Settings" and search for "errors". In the "Apple LLVM 6.1 - Warning Policies" section, you should see an item called "Treat Warnings as Errors". Set that to Yes.
选择您的项目,然后选择目标。接下来选择“构建设置”并搜索“错误”。在“Apple LLVM 6.1 - 警告策略”部分,您应该看到一个名为“将警告视为错误”的项目。将其设置为是。
Now that warning will generate an error.
现在该警告将生成错误。