如何在OCLint中使用cocoapods集成项目?

时间:2023-01-24 00:25:49

I can build the project and generate OCLint report on a project without cocoapods but when integrated with cocoapods the build for project is successful but the build for OCLint results into errors for the file which are present into cocoapods and build fails.

我可以构建项目并在没有cocoapods的项目上生成OCLint报告,但是当与cocoapods集成时,项目的构建是成功的,但是OCLint的构建导致文件的错误,这些错误存在于cocoapods中并且构建失败。

如何在OCLint中使用cocoapods集成项目?

So how to make build successful for cocoapods with OCLint?

那么如何使用OCLint使cocoapods成功构建?

Any help would be appreciated.

任何帮助,将不胜感激。

1 个解决方案

#1


Below is the script I am using to generate html file for cocoapods integrated project with OCLint.

下面是我用来为带有OCLint的cocoapods集成项目生成html文件的脚本。

OCLINT_HOME is the path for oclint downloaded folder. I have renamed the folder to oclintrelease.

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:/'

It will exclude all the Pods related files.

它将排除所有Pods相关文件。

If you want to include Pods file as well then replace last line in script by :

如果您还要包含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:/'

Notes :

  1. Please try first with a short sample Application including cocoapods and once you have generated report for sample application then integrate script into your real application as building with OCLint takes a lot of time to generate the report.
  2. 请先使用包含cocoapods的简短示例应用程序尝试,然后在为示例应用程序生成报告后,将脚本集成到您的实际应用程序中,因为使用OCLint构建需要花费大量时间来生成报告。

  3. Always clean application and then build with OCLint.
  4. 始终清理应用程序,然后使用OCLint构建。

Link for reference

链接供参考

#1


Below is the script I am using to generate html file for cocoapods integrated project with OCLint.

下面是我用来为带有OCLint的cocoapods集成项目生成html文件的脚本。

OCLINT_HOME is the path for oclint downloaded folder. I have renamed the folder to oclintrelease.

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:/'

It will exclude all the Pods related files.

它将排除所有Pods相关文件。

If you want to include Pods file as well then replace last line in script by :

如果您还要包含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:/'

Notes :

  1. Please try first with a short sample Application including cocoapods and once you have generated report for sample application then integrate script into your real application as building with OCLint takes a lot of time to generate the report.
  2. 请先使用包含cocoapods的简短示例应用程序尝试,然后在为示例应用程序生成报告后,将脚本集成到您的实际应用程序中,因为使用OCLint构建需要花费大量时间来生成报告。

  3. Always clean application and then build with OCLint.
  4. 始终清理应用程序,然后使用OCLint构建。

Link for reference

链接供参考