我们正在执行https://github.com/realm/SwiftLint的指令。
1.在终端CD中->项目目录
- touch .swiftlint.yml
1.打开.swiftlint.yml
并增加了以下规则
# By default, SwiftLint uses a set of sensible default rules you can adjust:
disabled_rules: # rule identifiers turned on by default to exclude from running
- colon
- comma
- control_statement
– compiler_protocol_init
– cyclomatic_complexity
– file_length
– force_cast
– function_body_length
– function_parameter_count
– identifier_name
– multiple_closures_with_trailing_closure
– notification_center_detachment
– line_length
– trailing_whitespace
– type_body_length
– type_name
– todo
- shorthand_operator
opt_in_rules: # some rules are turned off by default, so you need to opt-in
- empty_count # Find all the available rules by running: `swiftlint rules`
# Alternatively, specify all rules explicitly by uncommenting this option:
# only_rules: # delete `disabled_rules` & `opt_in_rules` if using this
# - empty_parameters
# - vertical_whitespace
included: # paths to include during linting. `--path` is ignored if present.
- Kuwy
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Source/ExcludedFolder
- Source/ExcludedFile.swift
- Source/*/ExcludedFile.swift # Exclude files with a wildcard
analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
- explicit_self
# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
force_try:
severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 500
# they can set both implicitly with an array
type_body_length:
- 300 # warning
- 400 # error
# or they can set both explicitly
file_length:
warning: 500
error: 1200
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
type_name:
min_length: 4 # only warning
max_length: # warning and error
warning: 40
error: 50
excluded: iPhone # excluded via string
allowed_symbols: ["_"] # these are allowed in type names
identifier_name:
min_length: # only min_length
error: 4 # only error
excluded: # excluded via string array
- id
- URL
- GlobalAPIKey
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging)
在BuildPhase中添加了以下脚本
export PATH="$PATH:/opt/homebrew/bin"
if which swiftlint > /dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
也试着跟着脚本走
"${PODS_ROOT}/SwiftLint/swiftlint"
但我仍然得到错误,和Pods目录不排除.有人请帮助这个。
请找到SSx 1c 0d1x
是否缺少其他配置?
我通过以下方式安装了SwiftLint
使用Homebrew:
brew install swiftlint
使用CocoaPods:只需将以下行添加到您的Podfile:
pod 'SwiftLint'
1条答案
按热度按时间xdnvmnnf1#
我相信在系统中安装lint包比安装pod更好
1.此存储库有SwiftLint.pkg。下载并安装到您的系统https://github.com/realm/SwiftLint/releases
1.点击brew安装swiftlint
3.在Xcode中添加运行脚本阶段。
1.构建并运行项目,你就可以开始了。不要忘记在项目中添加.swiftlint.yml
我已经使用了exclude/disabled_rules作为参考,如下所示,它正在工作