SwiftLint

Setup in a Project

Configures autofix and unfixable errors reported inline in Xcode

  • Project > Build Phases > New Run Script Phase
  • Put it after Compile Sources
if [[ "$(uname -m)" == arm64 ]]; then
    export PATH="/opt/homebrew/bin:$PATH"
fi

if which swiftlint>/dev/null; then
  swiftlint --fix && swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

Customizing Rules

Add .swiftlint.yml to root of Xcode project.

disabled_rules:
  - closure_parameter_position

opt_in_rules:
  - accessibility_label_for_image