1

我正在尝试让 OCLint 与 iOS 项目一起工作。我已经使用 Brew 安装了 OCLint,并且安装正确(我可以通过运行 oclint 命令签入终端)。

我试图通过创建一个单独的目标(这里的教程)并创建一个新的运行脚本来集成它。当我构建新目标时,它会生成一个 report.html 文件,但没有扫描任何文件,Total Files = 0 :/

我怎样才能让它扫描我的项目?非常感谢。

我的脚本如下:

OCLINT_HOME=/Users/johndoe/Documents/Programs/oclint-0.8.1
export PATH=$OCLINT_HOME/bin:$PATH

hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi

cd ${TARGET_TEMP_DIR}

if [ ! -f compile_commands.json ]; then
echo "[*] compile_commands.json not found, possibly clean was performed"
echo "[*] starting xcodebuild to rebuild the project.."
# clean previous output
if [ -f xcodebuild.log ]; then
rm xcodebuild.log
fi

cd ${SRCROOT}

xcodebuild clean

#build xcodebuild.log
xcodebuild | tee ${TARGET_TEMP_DIR}/xcodebuild.log
#xcodebuild <options>| tee ${TARGET_TEMP_DIR}/xcodebuild.log

echo "[*] transforming xcodebuild.log into compile_commands.json..."
cd ${TARGET_TEMP_DIR}
#transform it into compile_commands.json
oclint-xcodebuild

fi

echo "[*] starting analyzing"
cd ${TARGET_TEMP_DIR}

oclint-json-compilation-database -v oclint_args "-report-type html -o $OCLINT_HOME/report.html"
4

2 回答 2

0

从你的终端试试这个。

echo "Opening workspace for OCLint detection"
open -a "/Applications/Xcode.app" PATH_TO_YOUR_WORKSPACE
sleep 20
echo "Starting OCLint Check......"
rm -Rf $(pwd)/compile_commands.json
rm -Rf $(pwd)/xcodebuild.log
xcodebuild -target TARGET -configuration Release -scheme OCLint -sdk iphonesimulator
xcodebuild -sdk iphonesimulator | tee xcodebuild.log
oclint-xcodebuild xcodebuild.log
oclint-json-compilation-database -- -o=report.html
oclint-json-compilation-database -v oclint_args "-report-type html -o report.html -rc=LONG_LINE=120" open compile_commands.json open report.html
echo "Finished executing OCLint..."
echo "Closing Xcode"
killall Xcode
exit 0

仅当您的方案未被检测到时才打开和关闭 Xcode。

于 2015-07-22T06:00:22.693 回答
0

请在您的终端上尝试此命令。在您的路径目录中

xcodebuild -project DemoCustomOCLint.xcodeproj -arch i386 -sdk 
iphonesimulator11.0 | xcpretty -r json-compilation-database -o compile_commands.json

oclint-json-compilation-database -v -- -report-type html -o report777.html

oclint-json-compilation-database
于 2017-11-03T10:06:16.357 回答