3

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.

Nevin Raj Victor
  • 2,924
  • 3
  • 23
  • 37

1 Answers1

4

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.

Dheeraj Singh
  • 5,143
  • 25
  • 33
  • Is there a way to generate html report even if build fails? – Nevin Raj Victor May 06 '15 at 05:52
  • 1
    if your project build is successful only then u can generate. if your oclint build fails then also html report is generated. – Dheeraj Singh May 06 '15 at 06:15
  • So it's like when we run oclint ,first errors are checked and if successfull it will build the project.Is it? – Nevin Raj Victor May 06 '15 at 06:20
  • yes , it builds and generates report. if you don't have errors in your project i t would generate html report. – Dheeraj Singh May 06 '15 at 06:23
  • Some times OCLint is givinf empty results even if there are issues in code. What might be the reason? – Nevin Raj Victor Jul 21 '15 at 05:05
  • It happens sometimes but just try cleaning the project and then again build it. – Dheeraj Singh Jul 21 '15 at 05:31
  • `xctool -workspace my.xcworkspace -scheme OCLint -reporter json-compilation-database:compile_commands.json clean build`. This does clean and build as well. Only one project generates empty reports while another project creates proper report. Is this an issue with my project. I am using the same script in both the projects. From Xcode also the same. – Nevin Raj Victor Jul 21 '15 at 05:35