SwiftLint
SwiftLint copied to clipboard
Adding support for Package Manager Extensible Build Tools (SE-0303).
While SwiftLint works correctly when working on a normal Xcode project that allows adding run scripts, working on a package for the Swift Package Manager is a whole other can of worms. Since there is no possible way for adding custom run scripts to swift packages, there is no possible customization.
To this problem, Apple has released SE-0303 which introduces a new SwiftPM target type called plugin, which basically are Swift targets that use specialized API in a new PackagePlugin library that is provided by SwiftPM, to configure commands that will run during the build.
I believe this was already introduced in Swift 5.5 most recent beta. It would be really nice to have these new features implemented in SwiftLint so that we can also see syntax corrections on Swift packages.
Thanks!
The build tool plugins introduced in SE-0303 won't work here (at least, not if we want to support --fix), as explained in SE-0332:
The build tool plugins that were introduced in SE-0303 are focused on code generation during the build of a package, for such purposes as generating Swift source files from .proto files or from other inputs. In order to allow build tools to be incorporated into the build graph and to run automatically in a safe manner, there are restrictions on what such plugins can do. For example, build tool plugins are prevented from modifying any files inside a package directory.
What we'll want is a PackageModel.PluginCommandIntent.sourceCodeFormatting as was introduced in SE-0332. Though it looks like the these plugins can't be run automatically during a build, and Xcode doesn't expose any UI for them yet.
Done in 3fd1573c572f5d960d8e8b3bc46bc229c969ddcb