OCLint not in system path

2019-02-25 15:24发布

问题:

I have an Xcode project. I tried to integrate OcLint in it. But it says there is no OCLint.How can I download and addOCLint to my system path so that I can integrateOCLint in my xcode project.

EDIT:

When I have a partof OCLint script as

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

It gives oclint not found, analyzing stopped.

Please give me a solution for this.

回答1:

You can download oclint from : http://archives.oclint.org/nightly/oclint-0.9.dev.02251e4-x86_64-darwin-14.0.0.tar.gz

To integarte into your xcode project u could use this link :http://docs.oclint.org/en/dev/guide/xcode.html

Below is the script I am using to generate html file.

OCLINT_HOME is the path for oclint downloaded folder. I have renamed the folder to 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 "[*] 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"

Your report would be generated to the provided path in OCLINT_HOME using the above script.

If you want to generate report in your derived data folder then replace the last line with :

oclint-json-compilation-database -v oclint_args "-report-type html -o report.html"

HTML report would be generated if and only if your build is successful and you can check your generated report path and script report into Log Navigator of Xcode.