Apple Silicon(M1, M2 등)에서 Homebrew를 통해 SwiftLint를 설치한 경우, 빌드 시에 아래와 같은 경고가 발생한다.
warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint
👉 이는 Apple Silicon에서 Homebrew가 기본적으로 /opt/homebrew/bin
폴더에 바이너리를 설치하는데, Xcode가 해당 경로를 몰라서 SwiftLint를 찾지 못하기 때문에 나타나는 경고이다.
✅ Xcode 프로젝트의 Build Phase 옵션에서 추가해준 SwiftLint 실행 스크립트에서 PATH
환경 변수에 /opt/homebrew/bin
경로를 지정해주면 된다.
**if [[ "$(uname -m)" == arm64 ]]; then
export PATH="/opt/homebrew/bin:$PATH"
fi**
if which swiftlint > /dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from <https://github.com/realm/SwiftLint>"
fi
나는 M1 맥북을 사용 중이기 때문에 환경변수에 경로를 추가해주었다.
✅ 아니면 실제 바이너리를 가리키도록 /usr/local/bin
경로에 symbolic link를 만들어줄 수 있다.
ln -s /opt/homebrew/bin/swiftlint /usr/local/bin/swiftlint