Jay Graves

Use the Latest Version of Clang

Update You must use an absolute path in step 3 or you could get a crash. Thanks @hyperjeff

At the time of this writing the latest version of Xcode (4.3.2) was released on March 22nd 2012. The latest version of Clang (267) was released on June 1 2012. There have been 4 updates to Clang since Xcode 4.3.2 has shipped and those updates fix bugs and add better support for blocks. See the Clang release notes.

It is really easy to take advantage of these updates on your development machine or on your build servers.

On your local development machine

  1. Download Clang curl -L -o clang.tar.bz2
  2. Untar it tar -jxvf clang.tar.bz2
  3. Tell Xcode about the updated Clang sudo ./checker-267/set-xcode-analyzer --use-checker-build=$ABSOLUTE_PATH_TO_CLANG

Now Xcode will use this updated version of Clang instead of the built in version. If you ever want to change back you run sudo ./checker-267/set-xcode-analyzer --use-xcode-clang

On your build servers

The Jenkins Clang Scan-Build Plugin has settings that define where Clang lives outside of Xcode. I install Clang in /usr/local/bin/checker

Clang Scan-Build Plugin Settings

With all that done you can now enjoy the benefits of the most up to date static code analysis.

Also, I love the graphs that the Clang Scan-Build Plugin creates