Lukas Pistrol Logo

Lukas Pistrol

SwiftLint SPM Plugin

To make it easier to include this plugin into your packages until SwiftLint themselves add an official plugin, I created a small package that can be added through Swift Package Manager (SPM).

Add the package as a dependency to your Package.swift:

dependencies: [
  // ...
  .package(url: "", from: "0.0.1"),

After that simply add it as a plugin to all your targets you want SwiftLint to work on:

targets: [
    name: "YOUR_TARGET",
    dependencies: [],
    plugins: [
      .plugin(name: "SwiftLint", package: "SwiftLintPlugin")

Now just let the package manager handle the new dependencies and build your selected target. In case there are any linting warnings or errors, they will show up as warning or errors respectively in Xcode.

One small sidenote I have to mention though is that currently you might only want to use this in your local environment since many CI/CD services like GitHub Actions might not support Swift 5.7 yet.


Thanks to Marco Eidinger who pointed out that plugins work from Swift 5.6 onward. Changed the swift-tools-version to 5.6 in an update (0.0.2)

Another article you might like: