12

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.

agreendev
  • 309
  • 1
  • 3
  • 9

4 Answers4

25

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
Sean Kladek
  • 4,396
  • 1
  • 23
  • 29
6

Since 0.43.0 versión, you need to specify a path relative to the current working directory, so you can use ${PWD}:

excluded:
  - ${PWD}/Pods
pableiros
  • 14,932
  • 12
  • 99
  • 105
0

Although this wasn't the OP's problem, I came across this page and my problem was that my swiftlint.yml wasn't added as .swiftlint.yml

0

My solution was moving ".swiftlint.yml" file to the root of the project with finder. Then I've moved from finder to my Xcode project structure.