Skip to content
Latchkey

How to Run SwiftLint in GitHub Actions

Install SwiftLint with Homebrew and run it in strict mode so any warning fails the CI job.

SwiftLint ships as a Homebrew formula. Install it, then run swiftlint lint --strict so warnings become errors and the gate is enforced. Use --reporter github-actions-logging for inline annotations.

Steps

  • Install SwiftLint with brew install swiftlint.
  • Run swiftlint lint --strict to fail on any violation.
  • Add --reporter github-actions-logging for inline PR annotations.

Workflow

.github/workflows/ci.yml
jobs:
  lint:
    runs-on: macos-latest
    env:
      HOMEBREW_NO_AUTO_UPDATE: '1'
    steps:
      - uses: actions/checkout@v4
      - run: brew install swiftlint
      - run: swiftlint lint --strict --reporter github-actions-logging

Gotchas

  • --strict turns warnings into a non-zero exit, so an unfixed warning blocks the merge.
  • Commit a .swiftlint.yml so local and CI runs use the same enabled rules.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →