iosswiftcocoapodsswiftlint

Excluding Pods from SwiftLint configuration


I'm integrating SwiftLint, via Cocoapods, into an existing project.

My project directory is as such:

AppNameRepo
|-- AppName
|   |--.swiftlint.yml
|--AppName.xcworkspace
|--Pods

And my .swiftlint.yml, as I've tried to exclude pods:

included: # paths to include during linting. `--path` is ignored if present.
- Project
- ProjectTests
- ProjectUITests
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Pods
- ../Pods
- ./Pods
- /Pods
- Project/R.generated.swift
- Project/Pods

I don't really understand what it's resolving the 'Project' tag to, so I'm grasping at straws here to get to exclude the Pod directory that's up a level from where the .swiftlint.yml file resides. I tried moving the .swiftlint.yml up a level, so it sat along side /AppName and /Pods, but then no matter what I changed on the included (which, I didn't think would need to be changed as I assumed it recursively worked in), swiftlint would claim there was no lintable files, so I'm at a loss for next steps.


Solution

  • Swiftlint is resolving paths relative to itself. Move the .swiftlint.yml file up a level. Project should be changed to reflect your AppName folder rather than the project name. Your swiftlint file will look like this:

    included:
      - AppName
    
    excluded:
      - Pods