Xcode Build and Analyze - Is it possible to purposely skip analysis on a particular file?
If it's OK to edit the file, there's a brute force option.
Add this to the beginning of the file:
// Omit from static analysis.
#ifndef __clang_analyzer__
Add this to the end:
#endif // not __clang_analyzer__
and the clang analyzer won't see the contents of the file.
reference: Controlling Static Analyzer Diagnostics
Same idea as this answer only for analysis -> Ignore all warnings in a specific file using LLVM/Clang
You can include a "compile sources" argument in the "Build Phases" tab of the project settings to ignore a specific file from the analyzer. Here are some instructions:
- Select the target for the project you want to change.
- Select the build phase tab.
- Expand the "Compile Sources" menu.
- Find the file to edit.
- Double click its "Compiler Flags" cell to change the arguments.
- Add
-Xanalyzer -analyzer-disable-checker
, or-Xanalyzer -analyzer-disable-all-checks
for Xcode 10 and after - Optionally add
-Wno-unused-command-line-argument
as well, if Xcode complains that-Xanalyzer
is unused during regular compiles and you want to keep your build clean
Note: adding -w will also disable warnings on a particular file as well.