This is an experiment using the
pre-commit hook with SwiftLint.
How it’s works?
First, to generate the
swiftlint log, I added a Build Phase Script on Xcode using the
> operator to output directly on a file named
Don’t forget to add the
swiftlint.txt to your
pre-commit script will check if this file has a
warning string using the
warnings="$(grep -q "warning" swiftlint.txt)" if $warnings > 0 ; then if $warnings > 1; then cecho "RED" "⚠️ Check these warnings before your commit ⚠️" else cecho "RED" "⚠️ Check this warning before your commit ⚠️" fi cecho "YELLOW" "$(<swiftlint.txt)" exit 0 fi
Then you have a nice output