OCLint

Using OCLint with xcpretty

This document goes through using xcpretty inside OCLint’s workflow for analyzing the code quality for a Xcode project.

Generating json-compilation-database with xcpretty

Running xcpretty is quite straight forward. For example, the command below will build the project and generate the compile_commands.json file under the current folder.

xcodebuild [flags] | xcpretty -r json-compilation-database -o compile_commands.json

If you want to preserve the raw xcodebuild output, then you can do

xcodebuild [flags] | tee xcodebuild.log | xcpretty -r json-compilation-database -o compile_commands.json

Running oclint-json-compilation-database

Now, by having the compile_commands.json file, we can run the code analysis by simply call

oclint-json-compilation-database

Or with your customizations.