Search code examples
swiftxcodexcode8swift3

How to suppress warnings in Swift 3?


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?


Solution

  • 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:

    for all files

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

    for one file