我找不到如何永久修改Xcode构建阶段脚本的$PATH变量。此脚本将在运行期间将Apple Silicon Homebrew路径添加到您的脚本路径中。我已在M1和Intel Mac上测试过,对两者都有效。
# Adds support for Apple Silicon brew directory
export PATH="$PATH:/opt/homebrew/bin"
if which swiftlint; then
swiftlint —-fix && swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
swiftlint autocorrect
" 命令已不再可用,请使用 "swiftlint --fix
" 命令代替。(swiftlint
版本0.47.1) - l --marc l你也可以使用符号链接来链接路径
ln -s /opt/homebrew/bin/swiftlint /usr/local/bin/swiftlint
但要确保您先拥有/usr/local/bin文件夹
alias swiftlint="/opt/homebrew/bin/swiftlint"
if swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
====
另一种方法是改变相位脚本,但仍适用于英特尔和硅芯片。if test -d "/opt/homebrew/bin/"; then
PATH="/opt/homebrew/bin/:${PATH}"
elif test -d "${HOME}/Documents/SwiftLint"; then
PATH="${HOME}/Documents/SwiftLint:${PATH}"
fi
export PATH
if which swiftlint >/dev/null; then
${PODS_ROOT}/SwiftLint/swiftlint --config
${PROJECT_DIR}/.swiftlint.yml
else
echo "warning: SwiftLint not installed, download from
https://github.com/realm/SwiftLint"
fi.