缺少能够为每个目标定义配置文件的swiftlint runner
swiftlint-runner的Python项目详细描述
缺少Swiftlint Runner
缺少支持不同目标的xcode项目识别swiftlint runner。
动机
原始的swiftlint工具是xcode项目不可知的。这可能有问题。假设您想为生产和测试目标使用不同的swiftlint配置,并且您有一个目录结构,其中测试(spec)与生产代码混合在一起:
UI /
│
└── Controllers /
│
├── ViewController.swift
├── ViewControllerSpec.swift
└── Doubles
└── APIClientDouble.swift
到目前为止,swiftlint不支持递归glob模式,因此不能排除像**Doubles
这样的目录。
快速滑道
swiftlint runner列出特定目标下的所有swift文件,将其附加到指定的配置文件并对这些文件执行linting操作。
给定目录结构:
Project /
│
├── .swiftlint_sources.yml
├── .swiftlint_specs.yml
├── Project.xcodeproj
└── Controllers /
├── ViewController.swift
└── ViewControllerSpec.swift
两个名为Production
&;Specs
的目标可以使用swiftlint runner,如下所示:
slrunner Project.xcodeproj Production .swiftlint_sources.yml
slrunner Project.xcodeproj Specs .swiftlint_specs.yml
忘掉地球模式吧!
安装
swiftlint runner需要python 3.7。要安装它,只需运行:
pip install swiftlint-runner