在XCode中使用Clang静态分析器 [英] Using Clang Static Analyzer from within XCode

查看:149
本文介绍了在XCode中使用Clang静态分析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于当前项目目录没有Xcode脚本变量,如何创建一个脚本菜单项以从Xcode对当前项目运行Clang Static Analyzer?

Since there is no Xcode script variable for "current project directory," how can you create a script menu item to run the Clang Static Analyzer on your current project from Xcode?

推荐答案

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

这篇关于在XCode中使用Clang静态分析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆