如何在Xcode中显示cppcheck输出?

时间:2018-05-04 13:17:36

标签: xcode xcode9 code-analysis static-code-analysis cppcheck

我想直接在Xcode Issue Navigator中显示cppcheck输出。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

以下是一个简单的脚本,您可以在Xcode的Run Script Phase中添加Build Phases

#!/bin/bash
srcDir=src
if which cppcheck >/dev/null; then
cppcheck -j 4 --enable=all --inline-suppr $srcDir 2>cppcheck.txt 1>/dev/null
pwd=$(pwd)
sed "s|\[|${pwd}/|" cppcheck.txt | sed 's|\]: |: warning: |'
rm cppcheck.txt
else
echo "warning: cppcheck not installed, install here: http://brewformulas.org/Cppcheck"
fi