XCode Tip: Catch More Bugs With The Clang Analyzer

A few days ago, I learned from @coffmanben that XCode has a built-in Clang Static Analyzer. The Analyzer looks through your source code on each build and finds bugs in your C, C++, and Objective-C code. I’ve been using it for a day now, and really love seeing the logic flaws in my code that I can easily fix.

The errors show up in the Issue Navigator alongside with all the other issues in your code. Here is one issue I found in code I was using yesterday:

XCode Analyzer Issue Navigator

To turn on the Analyzer, just follow these simple steps:

  1. Go to your project’s Build Settings
  2. Search for the Analyze During ‘Build’ setting and expand it
  3. Select Yes for the Debug option

XCode Analyze During Build

Happy Debugging!

Enjoy the article? Join over 14,500+ Swift developers and enthusiasts who get my weekly updates.