skip to Main Content

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.

3

Answers


  1. 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 future versions of SPM will support it.

    Currently, I use the 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
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. Ok, SwiftLint just updated main repository, commit 3fd1573 added support through SwiftPM & Run Build Tool Plug-ins. Take in account that you need Xcode 14 or later to use this approach.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search