Make static analysis failure cause build failure on Travis
The only way I could get this to work is to use the method detailed here
Add these two parameters to your xcodebuild
or scan -x
command
CLANG_ANALYZER_OUTPUT=plist-html \CLANG_ANALYZER_OUTPUT_DIR="$(pwd)/clang"
This will produce a HTML file if there are clang warnings. So check for existence of this file.
if [[ -z `find clang -name "*.html"` ]]; then echo "Static Analyzer found no issues"else echo "Static Analyzer found some issues" exit 123fi
I managed to work out a way to make this work with some help from this blog post. Here are the relevant parts of a sample .travis.yml
file:
language: objective-crvm: - 2.2.4osx_image: xcode7.3install: - gem install xcpretty --no-rdoc --no-ri --no-document --quiet - export PYTHONUSERBASE=~/.local - easy_install --user scan-buildscript: # use scan-build with --status-bugs to fail the build for static analysis warnings per http://jonboydell.blogspot.ca/2013/02/clang-static-analysis.html - export PATH="${HOME}/.local/bin:${PATH}" # I forget whether this was necessary. Try omitting it and see what happens! - set -o pipefail && scan-build --status-bugs xcodebuild analyze -workspace MyWorkspace.xcworkspace -scheme MyScheme -destination 'name=iPhone 6' ONLY_ACTIVE_ARCH=NO | xcpretty
I think you want to add -Wunused-value
to the Other Warning Flags section of your build settings and set "Treat Warnings as Errors" to Yes.