网上教程比较多,本文适合小白适用
1、安装
brew install swiftlint
2、根目录添加.swiftlint.yml(里面规则可以根据项目需要,适当修改)
# 黑名单,不检测哪些目录
excluded:
- Pods
# 行的长度
line_length:200
# 执行时排除掉的规则
disabled_rules:
- trailing_whitespace # 行末尾不加空格
- identifier_name # 参数变量命名规则
3、避免未安装swiftlint报错,在工程配置脚本即可
# Type a script or drag a script file from your workspace to insert its path.
ifwhich swiftlint >/dev/null;then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
网友评论