我可以构建项目并在没有 cocoapods 的项目上生成 OCLint 报告,但是当与 cocoapods 集成时,项目的构建是成功的,但是OCLint的构建会导致文件出现错误,这些错误存在于 cocoapods 中并且构建失败。
那么如何使用 OCLint 成功构建 cocoapods 呢?
任何帮助,将不胜感激。
我可以构建项目并在没有 cocoapods 的项目上生成 OCLint 报告,但是当与 cocoapods 集成时,项目的构建是成功的,但是OCLint的构建会导致文件出现错误,这些错误存在于 cocoapods 中并且构建失败。
那么如何使用 OCLint 成功构建 cocoapods 呢?
任何帮助,将不胜感激。
下面是我使用 OCLint 为 cocoapods 集成项目生成 html 文件的脚本。
OCLINT_HOME 是 oclint 下载文件夹的路径。我已将该文件夹重命名为 oclintrelease。
OCLINT_HOME=/Users/Dheeraj/Downloads/oclintrelease
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 "Workspace Path : ${MY_WORKSPACE}"
echo "[*] starting xcodebuild to rebuild the project.."
# clean previous output
if [ -f xcodebuild.log ]; then
rm xcodebuild.log
echo "Oclint Clean performed"
fi
cd ${SRCROOT}
xcodebuild clean
#build xcodebuild.log
xcodebuild ONLY_ACTIVE_ARCH=NO -workspace ${PROJECT_NAME}.xcworkspace -scheme ${PROJECT_NAME} -configuration Debug clean build| 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 -e /Users/Dheeraj/Desktop/sampleCocoaPods/Pods/ -v oclint_args "-report-type html -o /Users/Dheeraj/NewHTMLREPORT.html" | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'
它将排除所有 Pod 相关文件。
如果您还想包含 Pods 文件,则将脚本中的最后一行替换为:
oclint-json-compilation-database -v oclint_args "-report-type html -o /Users/Dheeraj/NewHTMLREPORT.html" | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'
备注: