agreendev
agreendev

Reputation: 319

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.

Upvotes: 13

Views: 12503

Answers (4)

Emirhan Karahan
Emirhan Karahan

Reputation: 140

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.

Upvotes: 0

Joe Zhou
Joe Zhou

Reputation: 21

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

Upvotes: 1

pableiros
pableiros

Reputation: 16022

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

Upvotes: 8

Sean Kladek
Sean Kladek

Reputation: 4446

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

Upvotes: 27

Related Questions