Using Clang Static Analyzer from within Xcode

From the XCode script menu item, "Edit User Scripts" enter the following script:

#!/bin/bash
result=$( osascript << END
tell application "Xcode"
 tell active project document
  set projectPath to path as string
 end tell 
end tell 
return projectPath
END
)

cd "$result"

/Developer/clangchecker/scan-build -k -V xcodebuild -configuration Debug -sdk iphonesimulator3.0

Obviously, you will need to adjust the path to your install of Clang, and adjust to the version of the SDK you are using.

Remember to do a "Clean All" immediately before using scan-build, or the results may be incomplete.

Tags:

Xcode

Clang