Home > Net >  Is there any way to apply SwiftLint to SwiftPackages
Is there any way to apply SwiftLint to SwiftPackages

Time:01-28

I'm struggling to find a way to apply SwiftLint to my swift packages.
But after searching a lot, I couldn't find any way.

I use micro application architecture, which leads me to many micro packages. I am looking for a way to use SwiftLint for my swift packages.

CodePudding user response:

I have the same problem. The current version of SPM does not support Run Scripts so you can't run SwiftLint in a way like on the main project. But a future versions of SPM will support it.

Currently I use command line to find all the issues. This is not very convenient but something.

In the package folder:

swiftlint --config [path to swiftlint.yml] > [path to file to save a report]

e.g.

swiftlint --config ~/Desktop/swiftlint.yml > ~/Desktop/swiftlintreport.txt

CodePudding user response:

When I'm working on a SPM package I usually create an Xcode project that locally imports the package and use that project to work on the project.

This allows me to run stuff like SwiftLint. It's also handy to remember to use the correct access control modifiers.

You can see an example in this project of mine.

  •  Tags:  
  • Related