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.
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!
LikeLike
Hi!
I am trying to get this running. I made sure, that all the steps you suggested are done and I did a xcodebuild clean before running scan-build. Unfortunately, this runs and displays a webpage, which only describes errors related to compiling: Namely: “-miphoneos-version-min=2.2.1 is invalid, expected something like ‘2.0’.”.
Any Idea, what I can do to make this work for me? I really need help finding my leaks 🙂
LikeLike
It seem that it does not work for sdk 3.0 wrong gcc
LikeLike
You should still be able to get Clang open source to function with the current SDK (gcc 4.2). However, I suspect that if you wait until September, the workarounds to get the open source project will be mitigated.
LikeLike
Check dependencies
Code Sign error: The identity ‘iPhone Developer’ doesn’t match any valid certificate/private key pair in the default keychain
[BEROR]Code Sign error: The identity ‘iPhone Developer’ doesn’t match any valid certificate/private key pair in the default keychain
** BUILD FAILED **
– I got this error, what does it mean.
LikeLike
It means you don’t have your keys set up for code signing. Go to https://developer.apple.com/ios/manage/overview/, log in with your ADC account, and there’s both instructions and a wizard to help you get that all set up.
LikeLike