0

I want my Xcode project's tests to fail when there are analyzer warnings or errors.

Running the Xcode "Analyze" command points out the analyzer errors in your project:

Static Analyzer error

However, when I use Xcode's "Test" command on this same target I'm all green:

Passing tests

Is there a way to add a "Run Static Analyzer" test or build phase to the testing target? We are using XCTest. I find myself sometimes testing the target and thinking things are fine, only to have forgotten to fix a simple memory issue.

Our tests should fail when there are analyzer warnings or errors.

pkamb
  • 33,281
  • 23
  • 160
  • 191
  • Why aren't you using ARC? – Jon Shier Oct 02 '14 at 17:14
  • It's an older project that hasn't yet been converted to ARC, but that's beside the point; even under ARC the analyzer would complain about improper Core Foundation MRR and other errors. – pkamb Oct 02 '14 at 17:22

1 Answers1

1

You can set it to analyze during build in the build settings (just search for analyze). Set "Analyze during 'Build'" to YES.

Jon Shier
  • 12,200
  • 3
  • 35
  • 37
  • Thanks, that's good to know. I'd still like to see if there's a way to analyze only during tests, for faster normal builds. – pkamb Oct 02 '14 at 18:53
  • For that I would just create a separate Test configuration and set "Analyze during 'Build'" = YES for that configuration only. – Jon Shier Oct 03 '14 at 00:31