环境搭建:
brew cask install oclint
brew cask installxcpretty
oclint检测代码
$xcodebuild \
-workspace TALAccSDK.xcworkspace \
-scheme TALAccSDK \
-configuration Debug build \
| xcpretty \ #使用xcpretty将编译结果输出成后面需要的.json文件
-r json-compilation-database \
-o compile_commands.json
xcodebuild -workspace TALAccSDK.xcworkspace clean -scheme TALAccSDK -configuration Debug build | xcpretty -r json-compilation-database -o compile_commands.json
注:如果使用了clean命令,会清理编译缓存,本次操作需重新进行编译
$xcodebuild -workspace name.xcworkspace clean
oclint-json-compilation-database 转换.json文件为.html
$oclint-json-compilation-database \
-e Pods -- \
-report-type html \
-o oclintresult.html \
-rc LONG_LINE=9999 \ #添加一个检查规则:最长行数边界为9999,小于两千才可以通过检测:
-max-priority-1=9999 \
-max-priority-2=9999 \
-max-priority-3=9999
oclint-json-compilation-database -e Pods -- -report-type html -o oclintresult.html -rc LONG_LINE=9999 -max-priority-1=9999 -max-priority-2=9999 -max-priority-3=9999
报错:
1、multiple jobs问题
oclint: error: one compiler command contains multiple jobs:xxxx
基本出现在初次运行oclint或者使用了clean命令,清除了编译缓存之后,会出现下面的错误:
找到了一种解决方式:oclint: error: one compiler command contains multiple jobs解决方式
(更多依赖内容参考OCLint-内容扩展页面)
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['COMPILER_INDEX_STORE_ENABLE']= "NO"
end
end
end
网友评论