Skip to content

Instantly share code, notes, and snippets.

Created February 28, 2013 04:28
  • Star 48 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gavrix/5054182 to your computer and use it in GitHub Desktop.
Script integrating OCLint into XCode. Put it in "Run script" build phase.
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
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
xcodebuild clean
#build xcodebuild.log
xcodebuild | tee ${TARGET_TEMP_DIR}/xcodebuild.log
echo "[*] transforming xcodebuild.log into compile_commands.json..."
#transform it into compile_commands.json
#if [-d report.html]; then
#rm report.html
#run static analyzer
#oclint-json-compilation-database -- -o=./report.html -html
echo "[*] starting analyzing"
oclint-json-compilation-database | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'
Copy link

when using this with xcode, it has to run xcodebuild twice. is there any way to get the existing output from xcodebuild?

Copy link

gavrix commented Jun 6, 2019

It was tested on Xcode that was out 6 years. I'm sorry, I haven't tried on newer Xcode since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment