Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

treat specific warning as error Xcode

In the Build Settings is it possible to treat Specific warnings as Error instead of Treating all warnings are Errors.

This is a simple Switch statement checker in xcode :

GCC_WARN_CHECK_SWITCH_STATEMENTS = YES_Error 

instead of :

GCC_WARN_CHECK_SWITCH_STATEMENTS = YES 

But its not working for me.

like image 564
raghul Avatar asked Jun 05 '14 11:06

raghul


People also ask

How do I fix Xcode warnings?

However, if you trust Xcode enough, you can simply follow this shortcut to to automatically fix fixable warnings. control + option + command + F or Control ⌃ + Option ⌥ + Command ⌘ + F . This will fix all the fixable errors in current scope.

How do I silence warnings in Xcode?

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.


1 Answers

Treat specific warnings as errors

use -Werror=

for example: -Werror=unused-variable will treat unused variable as error, which originally treat as warning by -Wunused-variable flag

add these to Other Warning Flags in project setting.

Treat all warnings as errors except for some warnings

use -Werror and -Wno-error=

The first one will treat all warnings as errors, equals to the setting in Xcode.

And use -Wno-error= to make specific warning not be error. For example: -Wno-error=unused-variable

add these to Other Warning Flags in project setting.


Reference https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

For all warning flags https://clang.llvm.org/docs/DiagnosticsReference.html

like image 145
leavez Avatar answered Sep 19 '22 02:09

leavez