swiftlint autocorrect --config ".swiftlint.yml" --format
swiftlint lint --config ".swiftlint.yml"If your project has a lot of warnings, just run the following command to collect all rules:
swiftlint lint | grep -o '([A-Za-z].*)' | sed 's/[()]//g' | uniq -cIf you want to see only the list of rules run this command instead:
swiftlint lint | grep -o '([A-Za-z].*)' | sed 's/[()]//g' | uniqIn order to disable it you can use the following comment:
// swiftlint:disable rule_identifierAfter this comment to the end of the file, all checking for that rule becomes disabled. if you want to disable the rule only in the next line of code use the below comment:
// swiftlint:disable:next rule_identifierLikewise, you can disable the rule in the current line and previous line with swiftlint:disable:this and swiftlint:disable:previous respectively.
Add a build phase (before compile phase) with the following:
if which swiftlint >/dev/null; then
echo "Linting Code and Autocorrecting"
swiftlint autocorrect --config "$SRCROOT/.swiftlint.yml" --format
swiftlint lint --config "$SRCROOT/.swiftlint.yml"
#exit 0
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi