Search code examples
xcodetravis-cistatic-analysisxcodebuild

Why are static analyzer issues not failing my CI build?


I have a project on GitHub with an automated build on Travis CI. The current revision of my code (buildfix branch, commit 3ebc41a8b4738bce926b39cc3869c6dce8bed9bc) is succeeding, even though I have one static analyzer issue. This is the xcodebuild command:

xcodebuild -workspace UnrarKit.xcworkspace -scheme UnrarKit -sdk macosx -configuration Release analyze test

I also have "Treat Warnings as Errors" set to YES for the whole project (for Release builds). I get this output from xcodebuild:

The following commands produced analyzer issues:
  Analyze Classes/URKArchive.mm
(1 command with analyzer issues)

I reproduced this with xcodebuild in my local Terminal with the same result.

Why does xcodebuild still return 0 and allow my build to succeed? Why allow xcodebuild to analyze in the first place if the results can't be used? If it's a bug, I'll file it with Apple, but at the moment I'm open to the possibility I'm doing something wrong.


Solution

  • I think that it's the expected behavior to return 0. After all the last log is ** ANALYZE SUCCEEDED **. You can get html reports with

    xcodebuild -workspace UnrarKit.xcworkspace -scheme UnrarKit -sdk macosx -configuration Release analyze test CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer
    find analyzer -name *.html
    

    I'm also trying to find a way to make it return something else than 0, the only thing I came up with is:

    xcodebuild analyze ... && [[ -z `find analyzer -name "*.html"` ]]