ios - 如何将cocoapods集成项目与OCLint一起使用?

标签 ios objective-c cocoapods oclint

我可以在没有 cocoapods 的情况下构建项目并生成 OCLint 报告,但是当与 cocoapods 集成时,项目构建成功,但 OCLint 的构建会导致文件出现错误cocoapods 和构建失败。

enter image description here

那么如何使用 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:/'

注释:

  1. 请首先尝试使用包含 cocoapods 的简短示例应用程序,一旦为示例应用程序生成了报告,请将脚本集成到您的实际应用程序中,因为使用 OCLint 进行构建需要花费大量时间来生成报告。
  2. 始终清理应用程序,然后使用 OCLint 进行构建。

Link for reference

关于ios - 如何将cocoapods集成项目与OCLint一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30052657/

相关文章:

ios - Flutter build iOS 停留在为设备构建 [bundle id](iOS 版本)

objective-c - 单击时 UIButton 获得了他的默认文本

ios - CocoaPods 未检测到隐式依赖关系

ios - 如何管理 Podfile - iPhone、iPad 和 Mac 10.15 的部署

iPhone - NSDate 格式 : strange values for times and timezones

ios - TableView 滚动错误

ios - TableView 中的单元格展开未在 Swift 中正确显示

objective-c - 当我触摸键盘外部时,UIKeyboard 不会隐藏

ios - didSelectItemAtIndexPath 方法在 UICollectionView 中不起作用

ios - 单独的 Xcode 项目