https://github.com/lukepistrol/swiftlintplugin
A Swift Package Plugin for SwiftLint
https://github.com/lukepistrol/swiftlintplugin
build-tool-plugin command-plugin package-manager plugin spm swift swift5 swiftlint swiftpackagemanager xcode xcode14
Last synced: 27 days ago
JSON representation
A Swift Package Plugin for SwiftLint
- Host: GitHub
- URL: https://github.com/lukepistrol/swiftlintplugin
- Owner: lukepistrol
- License: mit
- Created: 2022-06-23T06:56:16.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-16T23:38:25.000Z (3 months ago)
- Last Synced: 2025-03-28T08:06:07.569Z (about 1 month ago)
- Topics: build-tool-plugin, command-plugin, package-manager, plugin, spm, swift, swift5, swiftlint, swiftpackagemanager, xcode, xcode14
- Language: Swift
- Homepage:
- Size: 47.9 KB
- Stars: 134
- Watchers: 5
- Forks: 26
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# SwiftLintPlugin
[](https://swiftpackageindex.com/lukepistrol/SwiftLintPlugin)
[](https://swiftpackageindex.com/lukepistrol/SwiftLintPlugin)
[](https://github.com/lukepistrol/SwiftLintPlugin/blob/main/LICENSE)
[](https://twitter.com/lukeeep_)A Swift Package Plugin for [SwiftLint](https://github.com/realm/SwiftLint/) that will run SwiftLint on build time and show errors & warnings in Xcode.
> **Note**
> There now is an official version in the [SwiftLint repo](https://github.com/realm/SwiftLint#plug-in-support)!
> Though this package will still be maintained and updated since it brings the benefit of being a smaller repository and
> therefore faster to download as a dependency## Add to Package
First add a dependency from this package:
```swift
dependencies: [
// ...
.package(url: "https://github.com/lukepistrol/SwiftLintPlugin", from: "0.2.2"),
]
```Then add it to your targets as a plugin:
```swift
targets: [
.target(
name: "YOUR_TARGET",
dependencies: [],
plugins: [
.plugin(name: "SwiftLint", package: "SwiftLintPlugin")
]
),
]
```## Add to Project
Starting with Xcode 14, plugins can also work on Xcode Project's targets. To do so, simply add this package to your SPM dependencies in Xcode. After that open your `target's settings > Build Phases` and add `SwiftLint` to `Run Build Tool Plug-ins` like shown below:
> You may need to enable & trust the plugin before you can actually run it during builds.
## Fix Warnings
As of version `0.1.0` this package also includes a command plugin which can be called on any target.
1. Select a project or package in the project navigator.
2. Richt-click and select `SwiftLintFix`.
- alternatively you can select `File > Packages > SwiftLintFix`.
3. Choose the target(s) to run the `swiftlint --fix` command on.
## Run on CI
Important to notice is that when building a package/project on any CI provider (e.g. GitHub Actions) it is mandatory to pass the `-skipPackagePluginValidation` flag to the `xcodebuild` command. This will skip the validation prompt which in Xcode looks like this:
### Example
```bash
xcodebuild \
-scheme "$SCHEME" \
-destination "$PLATFORM" \
-skipPackagePluginValidation \ # this is mandatory
clean build
```If you need to disable linting (for release/app store builds), you can set`DISABLE_SWIFTLINT` environment variable
-----