Hi folks, I wanted to talk about Static Analysis in XCode. For you iPhone and Mac developers, this new feature available in Snow Leopard and xCode 3.2, the advanced warning identifier that goes hand in hand with your normal compiler, providing a richer and deeper understanding of your code. It looks for logical anomalies, such as memory leaks, something your normal run of the mil compiler does not find, all within the confines of not having to leave xCode. This tool is an excellent facilitator for early Objective-C developers like myself, by showing you how memory management works.
You access the analysis tool by going to Build > Build and Analyze, in your menu, which allows it to build and analyse, rather than run. If you manage to get a memory leak, the Static Analyzer will present the warning as follows:
If you had uninitialised code, your warning would look like this:
Creating a Static Analysis Build Configuration
To put this feature as part of your default configuration, such as to automatically analyse your code whenever you build your project, you create a custom build, by going to Debug Configuration, and duplicating the Debug configuration, opening it, and Enabling Static Analysis for this build configuration.
- This advanced analysis technology is powered by Clang Open Source project.
- Refer to Mac OSX Reference library for the article this post was based on, as well as more interesting development information.