Skip to content

tzraikov/SwiftLintPlugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Twitter: @lukeeep_

SwiftLintPlugin

A Swift Package Plugin for SwiftLint that will run SwiftLint on build time and show errors & warnings in Xcode. This plugin has been modified to support Xcode cloud.

Note There now is an official version in the SwiftLint repo!

Add to Package

First add a dependency from this package:

dependencies: [
    // ...
    .package(url: "https://github.com/tzraikov/SwiftLintPlugin", from: "0.5.4"),
]

Then add it to your targets as a plugin:

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:

Screen Shot 2022-09-02 at 09 33 23

You may need to enable & trust the plugin before you can actually run it during builds.

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:

Screenshot 2022-12-13 at 17 48 44

Example

xcodebuild  \
    -scheme "$SCHEME" \
    -destination "$PLATFORM" \
    -skipPackagePluginValidation \ # this is mandatory
    clean build

If you need to disable linting (for release/app store builds), you can setDISABLE_SWIFTLINT environment variable

About

A Swift Package Plugin for SwiftLint

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages