pkamb
pkamb

Reputation: 34983

Xcode: Adding a Test that fails when there are Static Analyzer warnings or errors?

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.

Upvotes: 0

Views: 579

Answers (1)

Jon Shier
Jon Shier

Reputation: 12770

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

Upvotes: 1

Related Questions