且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在XCode中使用Clang静态分析器

更新时间:2023-11-10 17:40:16

从XCode脚本菜单项编辑用户脚本输入以下脚本:

From the XCode script menu item, "Edit User Scripts" enter the following script:

#!/bin/bash
result=$( osascript << END
tell application "Xcode"
 tell active project document
  set projectPath to path as string
 end tell 
end tell 
return projectPath
END
)

cd "$result"

/Developer/clangchecker/scan-build -k -V xcodebuild -configuration Debug -sdk iphonesimulator3.0

显然,您需要调整Clang安装的路径,并根据您使用的SDK版本进行调整。

Obviously, you will need to adjust the path to your install of Clang, and adjust to the version of the SDK you are using.

记住要做一个全部清理在使用scan-build之前,或者结果可能不完整。

Remember to do a "Clean All" immediately before using scan-build, or the results may be incomplete.