I was unable to find how to modify the $PATH variable for Xcode build phase scripts permanently. This script will add the Apple Silicon homebrew path to your scripts PATH for the duration of the run. I’ve tested this on an M1 and Intel Mac and it works for both.
# 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