从 SwiftLint 配置中排除 Pod

问题描述 投票:0回答:4

我正在通过 Cocoapods 将 SwiftLint 集成到现有项目中。

我的项目目录是这样的:

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

还有我的 .swiftlint.yml,因为我尝试排除 pod:

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

我不太明白它将“Project”标签解析为什么,所以我在这里抓住了稻草,以排除比 .swiftlint.yml 文件所在的位置更高一级的 Pod 目录。我尝试将 .swiftlint.yml 向上移动一个级别,因此它与 /AppName 和 /Pods 并排,但无论我对包含的内容进行了什么更改(我认为不需要更改,因为我认为它递归地工作),swiftlint 会声称没有 lintable 文件,所以我对接下来的步骤不知所措。

ios swift cocoapods swiftlint
4个回答
25
投票

Swiftlint 正在解析相对于自身的路径。将

.swiftlint.yml
文件向上移动一级。应更改
Project
以反映您的 AppName 文件夹而不是项目名称。您的 swiftlint 文件将如下所示:

included:
  - AppName

excluded:
  - Pods

6
投票

0.43.0
版本开始,需要指定相对于当前工作目录的路径,所以可以使用
${PWD}
:

excluded:
  - ${PWD}/Pods

0
投票

虽然这不是OP的问题,但我遇到了这个页面,我的问题是我的

swiftlint.yml
没有添加为
.swiftlint.yml


0
投票

我的解决方案是使用 finder 将“.swiftlint.yml”文件移动到项目的根目录。然后我从 finder 转移到我的 Xcode 项目结构。

© www.soinside.com 2019 - 2024. All rights reserved.