OCLint with Xcode empty report

1k Views Asked by At

I'm trying to get OCLint working with a iOS project. I've installed OCLint using Brew and it has installed correctly (I can check in terminal by running the oclint command).

I've attempted to integrate it by creating a separate target (tutorial here) and creating a new run script. When I build the new target it generates a report.html file but it has no files scanned, Total Files = 0 :/

How can I get it to scan my project? Many thanks.

My script is below:

OCLINT_HOME=/Users/johndoe/Documents/Programs/oclint-0.8.1
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"
2

There are 2 best solutions below

0
On

Try this from your terminal.

echo "Opening workspace for OCLint detection"
open -a "/Applications/Xcode.app" PATH_TO_YOUR_WORKSPACE
sleep 20
echo "Starting OCLint Check......"
rm -Rf $(pwd)/compile_commands.json
rm -Rf $(pwd)/xcodebuild.log
xcodebuild -target TARGET -configuration Release -scheme OCLint -sdk iphonesimulator
xcodebuild -sdk iphonesimulator | tee xcodebuild.log
oclint-xcodebuild xcodebuild.log
oclint-json-compilation-database -- -o=report.html
oclint-json-compilation-database -v oclint_args "-report-type html -o report.html -rc=LONG_LINE=120" open compile_commands.json open report.html
echo "Finished executing OCLint..."
echo "Closing Xcode"
killall Xcode
exit 0

Open and close Xcode only if your scheme is not getting detected.

0
On

Please try this commands your terminal. In your path directory

xcodebuild -project DemoCustomOCLint.xcodeproj -arch i386 -sdk 
iphonesimulator11.0 | xcpretty -r json-compilation-database -o compile_commands.json

oclint-json-compilation-database -v -- -report-type html -o report777.html

oclint-json-compilation-database