In Xcode, how to suppress all warnings in specific source files?

XcodeWarnings

Xcode Problem Overview


In my application I use 3rd party code that triggers some warnings. I reviewed them and they can be safely ignored.

Now I want to "mark" a file somehow, so Xcode won't show any warnings for the code in that file.

How should I do that?

Xcode Solutions


Solution 1 - Xcode

Select your target and show Build Phases. Then enter the name of the file in the search box, 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.

Solution 2 - Xcode

Select Project in left navigator and select target go to build phase and Put -w in Build Phase of target file. It will hide all compiler warnings enter image description here

Solution 3 - Xcode

This works for Xcode 10.2+ and Swift 5

Manual fix:

Add -w -Xanalyzer -analyzer-disable-all-checks to the problematic file from Xcode > Project > Targets > Compile Sources > Double click the file where you want to turn off warnings.

Cocoapods Fix:

If you're trying to suppress warnings from a problematic pod, you can automatically suppress all warnings from the dependency with the inhibit_warnings flag in your podfile:

pod 'Kingfisher', '~> 4.6', :inhibit_warnings => true

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBobrovskyView Question on Stackoverflow
Solution 1 - XcodeJon ReidView Answer on Stackoverflow
Solution 2 - XcodeSpydyView Answer on Stackoverflow
Solution 3 - XcodeN SView Answer on Stackoverflow