How to Exclude Files/Folders for SwiftLint Using CocoaPods?

Refresh

December 2018

Views

293 time

3

The Problem

When building my xcode Swift project, I am getting violations from SwiftLint (i.e. Empty Count Violations) of files/folders that I exclude in my .swiftlint.yml file, but when specifying those files/folders in the excluded section, the violations still occur.

Code

.swiftlint.yml

included:

excluded:
  - Pods
  - myproject/API/api_implementation.swift
  - myproject/API

Build Phases Run Script

"${PODS_ROOT}/SwiftLint/swiftlint"

Project Structure

/projectroot
    .swiftlint.yml
    Pods/
    myproject/
        API/
            api_implementation.swift

Neither myproject/API/api_implementation.swift nor the entire directory myproject/API/ are excluded from the lint!

The Question

What is incorrect in terms of making this file and folder excluded from the lint? If my syntax is incorrect, what is the correct syntax? If my path is incorrect, where is the SwiftLint file run from? Interestingly, even though the .swiftlint.yml file is in the root of my project, the swiftlint file that is run is in Pods/SwiftLint/

Perhaps the way that Cocoapods requires additional integration for SwiftLint to work would cause this problem. I have tried, however, to empty the Build Phases Run Script, and have confirmed that the .swiftlint.yml file is indeed running on build.

Any help or thoughts would be appreciated!

1 answers

0

Синтаксис и содержимое ваших .swiftlint.ymlвыглядит правильно для меня, но мне интересно , если проблема сводится к группе против папок в Xcode?

SwiftLint смотрит только на месте исходных файлов на диске , а не использовать иерархию , показанную в Навигаторе проекта в Xcode. Вы должны убедиться , что файлы , которые вы ожидаете быть исключены, безусловно , в API каталоге , когда вы смотрите в Finder, а не только API группа в Xcode.