【问题标题】:Excluding Pods from SwiftLint configuration从 SwiftLint 配置中排除 Pod
【发布时间】:2018-12-15 04:58:53
【问题描述】:

我正在通过 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

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

【问题讨论】:

    标签: ios swift cocoapods swiftlint


    【解决方案1】:

    Swiftlint 正在解析相对于自身的路径。将.swiftlint.yml 文件上移一级。 Project 应更改为反映您的 AppName 文件夹而不是项目名称。您的 swiftlint 文件将如下所示:

    included:
      - AppName
    
    excluded:
      - Pods
    

    【讨论】:

      【解决方案2】:

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

      excluded:
        - ${PWD}/Pods
      

      【讨论】:

        【解决方案3】:

        虽然这不是 OP 的问题,但我遇到了这个页面,我的问题是我的 swiftlint.yml 没有添加为 .swiftlint.yml

        【讨论】:

          猜你喜欢
          • 2019-08-02
          • 1970-01-01
          • 2020-12-01
          • 2021-03-01
          • 2017-02-01
          • 2016-09-20
          • 1970-01-01
          • 2021-09-29
          • 2021-03-28
          相关资源
          最近更新 更多