views:

1063

answers:

3

I'd like to use clang on my Xcode iPhone project. However this is the getting started guide:

http://clang.llvm.org/get_started.html

I've been working with Xcode for a year but this is far far far from being understandable to me! Can anyone explain in plain english how to install and use Clang with my existing iPhone project? I am not familiar with loading things from the console.

Thanks!

Dan

+3  A: 
  1. Download and extract the clang distribution to some directory. Optionally add this directory to your path, or you can just prepend it's location to the command line later on.
  2. cd to your top level project directory (probably something like cd ~/Documents/yourprojectdirectory)
  3. Tell the clang utility to do a build of your project using your xcode project settings by typing in the following command line: pathtoclangdirectory/scan-build -o ./clang_out xcodebuild
  4. The utilty should give you a message after it has run successfully to run the scan_view utility.
  5. Run the command that was output at the end of the build. This will start a temporary web server on your machine and then open up Safari and show you the code analysis. You may need to prepend the path to your clang directory again, like so: pathtoclangdirectory/scan_view ...
drewh
Note: You can now download a compiled version of the Clang Static Analyzer for Leopard, rather than building your own. http://clang-analyzer.llvm.org/
Quinn Taylor
+7  A: 

Nikita Zhuk has wrapped Clang in a GUI and made it available at http://www.karppinen.fi/analysistool/. Very useful.

Ben Gottlieb
I tried this and found that the custom extenions to CLang for their inhouse coding styles make it less than useful.
Roger Nolan
I'm just ignoring their formatting bugs etc and focusing on the ones that are useful
Dan Morgan
I'm aware that some conventions which are used by AT may be problematic for other developers. Future AT version will allow user to select which analyses should be run.
Nikita Zhuk
Thanks For some reason I have been unable to run clang on a project linking to a static library but this GUI tool worked.
Corey Floyd
I also tried running clang on a static library and got errors (it simply said it failed to compile the classes...). @Nikita: AT is amazingly good and I am definitely making it a part of my work-flow. It would be great if you or anyone else could help out with the static library errors.
Felixyz
+1  A: 

I didn't see this question until after I had done something similar to make Clang more useful inside XCode:

http://stackoverflow.com/questions/961844/using-clang-static-analyzer-from-within-xcode

mmc