Debugging with Clang

2019-04-09 22:08发布

问题:

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

回答1:

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



回答2:

  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 ...


回答3:

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

Using Clang Static Analyzer from within XCode