我找到了这个shell脚本
# Run SwiftLint
START_DATE=$(date +"%s")
SWIFT_LINT=/usr/local/bin/swiftlint
# Run SwiftLint for given filename
run_swiftlint() {
local filename="${1}"
if [[ "${filename##*.}" == "swift" ]]; then
#${SWIFT_LINT} autocorrect --path "${filename}"
${SWIFT_LINT} lint --path "${filename}"
fi
}
if [[ -e "${SWIFT_LINT}" ]]; then
echo "SwiftLint version: $(${SWIFT_LINT} version)"
# Run for both staged and unstaged files
git diff --name-only | while read filename; do run_swiftlint "${filename}"; done
git diff --cached --name-only | while read filename; do run_swiftlint "${filename}"; done
else
echo "${SWIFT_LINT} is not installed."
exit 0
fi
END_DATE=$(date +"%s")
DIFF=$(($END_DATE - $START_DATE))
echo "SwiftLint took $(($DIFF / 60)) minutes and $(($DIFF % 60)) seconds to complete."在这里https://github.com/realm/SwiftLint/issues/413#issuecomment-184077062
它工作得很好,直到我把我的电脑升级到M1芯片。
根据这个博客https://www.anotheriosdevblog.com/installing-swiftlint-on-a-m1/,我们应该改变路径的位置。我怀疑这与SwiftLint的安装位置有关:
然而,我不太熟悉让它工作的自制脚本或shell脚本。
发布于 2021-11-23 14:51:54
新Mac上的Home位置已更改。
改变
SWIFT_LINT=/usr/local/bin/swiftlint至
SWIFT_LINT=/opt/homebrew/bin/swiftlint修复了该问题
https://stackoverflow.com/questions/70022168
复制相似问题