Oct 11
SeattleBus Diary: Using CLANG static analyzer with an iPhone project
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
- run
rm -rf /tmp/scan-build* - run
rm -rf build/;scan-build --view xcodebuild - Open Xcode and fix errors
That’s been working great for me ever since.

November 17th, 2008 at 10:34 am
Thanks for this! I ran scan-build on my project, but after going after the “low hanging fruit”, I had problems running it again. I would get some build errors that didn’t come with much explanation (and things built just fine with xCode). After running those “rm” commands, it worked great!
January 2nd, 2009 at 8:11 pm
[...] for device builds no … but the simulator uses Intel binaries! Convenient, no? Thanks to this post for explaining to us My workflow after I’ve really worked on the codebase is [...]