Swift lint


My notes on using swift-lint in XCode.

  1. install swift-lint: https://github.com/realm/SwiftLint/releases

  2. Add .swiftlint.yml to your xcode project folder
  3. Add swift-lint script to your xcodeproject:
  • XCode 👉 Build phases
  • Click “plus-button” 👉 Add run script
  • Paste in the bellow:
if which swiftlint >/dev/null; then
  swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
  1. Build the project to see some swift-lint warnings

  2. Add a swift-lint badge to your github project SwiftLint Sindre [![Swift-lint Sindre](https://img.shields.io/badge/swift--lint-sindre-brightgreen.svg)](https://github.com/sindresorhus/swiftlint-sindre) `