skip to Main Content

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.

3

Answers


  1. 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
    
    Login or Signup to reply.
  2. you can also symlink the path

    ln -s /opt/homebrew/bin/swiftlint /usr/local/bin/swiftlint
    

    But make sure you have /usr/local/bin folder first

    Login or Signup to reply.
  3. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search