Run swift code validation using SwiftLint

Supported platforms ios, mac
Author @KrauseFx

1 Example

  mode: :lint,      # SwiftLint mode: :lint (default) or :autocorrect
  path: "/path/to/lint",       # Specify path to lint (optional)
  output_file: "swiftlint.result.json", # The path of the output file (optional)
  config_file: ".swiftlint-ci.yml",     # The path of the configuration file (optional)
  files: [# List of files to process (optional)
  raise_if_swiftlint_error: true,      # Allow fastlane to raise an error if swiftlint fails
  ignore_exit_status: true    # Allow fastlane to continue even if SwiftLint returns a non-zero exit status



Key Description Default
mode SwiftLint mode: :lint, :fix, :autocorrect or :analyze :lint
path Specify path to lint
output_file Path to output SwiftLint result
config_file Custom configuration file of SwiftLint
strict Fail on warnings? (true/false) false
files List of files to process
ignore_exit_status Ignore the exit status of the SwiftLint command, so that serious violations don't fail the build (true/false) false
raise_if_swiftlint_error Raises an error if swiftlint fails, so you can fail CI/CD jobs if necessary (true/false) false
reporter Choose output reporter. Available: xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging
quiet Don't print status logs like 'Linting ' & 'Done linting' false
executable Path to the swiftlint executable on your machine
format Format code when mode is :autocorrect false
no_cache Ignore the cache when mode is :autocorrect or :lint false
compiler_log_path Compiler log path when mode is :analyze

* = default value is dependent on the user's system


To show the documentation in your terminal, run

fastlane action swiftlint


It is recommended to add the above action into your Fastfile, however sometimes you might want to run one-offs. To do so, you can run the following command from your terminal

fastlane run swiftlint

To pass parameters, make use of the : symbol, for example

fastlane run swiftlint parameter1:"value1" parameter2:"value2"

It's important to note that the CLI supports primitive types like integers, floats, booleans, and strings. Arrays can be passed as a comma delimited string (e.g. param:"1,2,3"). Hashes are not currently supported.

It is recommended to add all fastlane actions you use to your Fastfile.

Source code

This action, just like the rest of fastlane, is fully open source, view the source code on GitHub

Back to actions