xcodeswiftlintapple-silicon

Swiftlint can't be found on Apple Silicon xcode


When installing swiftlint with homebrew everything installs correctly but when I open xcode I see the message that swiftlint isn't installed. I read this issue & it say's the homebrew installs under this path now /opt/homebrew with apple silicon & xcode looks for swiftlint in /usr/local? How can I get xcode to reconige that I have in fact installed swiftlint. Swiftlint is definitely installed, from terminal I can type swiftlint & see all the commands.


Solution

  • 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