Like a number of other Mac developers, I caught the word and then the bug for using Clang Static Analyzer. I remember when I first caught wind of it, hearing about it on twitter and spotting a number of del.icio.us links to it. The note that really caught my attention was someone mentioning it and saying “too bad you can’t use it with the iPhone development…”.
That completely surprised me, because the first project I tried it on was SeattleBus. It was great for identifying a few memory leaks and missing -dealloc methods, I was hooked right off the bat. It wasn’t until later that I started trying to figure out that statement and realized that the analyzer doesn’t support analyzing ARM binaries. It does a great job on intel binaries though, so I realized that when I set my project to default to building for the simulator, I could use the analysis program.
My workflow after I’ve really worked on the codebase is now:
- Make sure the project default settings are “debug” and “simulator”
- Close Xcode
- open a terminal window and “cd” to the project directory
rm -rf /tmp/scan-build*
rm -rf build/;scan-build --view xcodebuild
- Open Xcode and fix errors
That’s been working great for me ever since.