'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 1:[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 autocorrect && swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

Solution 2:[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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Justin
Solution 2 Manish Agrawal