-
-
Save coryalder/6effee57a123420f2f949955f039fcee 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
#!/bin/bash | |
# https://gist.github.com/gavrix/5054182 original | |
source ~/.bash_profile | |
hash oclint &> /dev/null | |
if [ $? -eq 1 ]; then | |
echo >&2 "oclint not found, analyzing stopped" | |
exit 1 | |
fi | |
echo "[*] copying rules to tmp dir" | |
cp ${SRCROOT}/.oclint ${TARGET_TEMP_DIR}/.oclint | |
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 | xcpretty -r json-compilation-database --output ${TARGET_TEMP_DIR}/compile_commands.json | |
fi | |
#run static analyzer | |
echo "[*] starting analyzing" | |
cd ${TARGET_TEMP_DIR} | |
oclint-json-compilation-database -- -report-type xcode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment