-
-
Save ryuichis/755e6297aec13c900cdf to your computer and use it in GitHub Desktop.
Script integrating OCLint into XCode. Put it in "Run script" build phase.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source ~/.bash_profile | |
cd ${SRCROOT} | |
xcodebuild clean | |
xcodebuild | xcpretty -r json-compilation-database | |
oclint-json-compilation-database -- -report-type xcode |
worked with Xcode 11.2.1
source ~/.bash_profile
unset LLVM_TARGET_TRIPLE_SUFFIX
xcodebuild clean
xcodebuild COMPILER_INDEX_STORE_ENABLE=NO | xcpretty -r json-compilation-database --output compile_commands.json
# Rules
LINT_LONG_LINE=300
LINT_LONG_VARIABLE_NAME=64
LINT_LONG_METHOD=150
LINT_RULES="-rc LONG_LINE=${LINT_LONG_LINE} \
-rc LONG_VARIABLE_NAME=${LINT_LONG_VARIABLE_NAME} \
-rc LONG_METHOD=${LINT_LONG_METHOD}"
# Threshold.
LINT_PRIORITY_1_THRESHOLD=0
LINT_PRIORITY_2_THRESHOLD=20
LINT_PRIORITY_3_THRESHOLD=30
LINT_THRESHOLD = "-max-priority-1=${LINT_PRIORITY_1_THRESHOLD} \
-max-priority-2=${LINT_PRIORITY_2_THRESHOLD} \
-max-priority-3=${LINT_PRIORITY_3_THRESHOLD}"
# Excludes
# you can use grep-like regular expressions syntax,
LINT_EXCLUDES="Pods|lib"
oclint-json-compilation-database \
-exclude ${LINT_EXCLUDES} \
-- \
-report-type xcode \
${LINT_RULES} \
${LINT_THRESHOLD} \
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was recently having some trouble getting this working on a project using Xcode 10 and OCLint 0.13.1. Here's a summary of some of the errors I saw and how I resolved them:
COMPILER_INDEX_STORE_ENABLE=NO
build flag to my mainxcodebuild
step.unset LLVM_TARGET_TRIPLE_SUFFIX
to the top of the script.I've got a working version of the script that contains the above fixes in my fork. Also including it below (again, you will need to replace
<project_name>
with appropriate values and likely tweak the-exclude
flags):