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.
            Asked
            
        
        
            Active
            
        
            Viewed 1.1k times
        
    44
            
            
         
    
    
        user
        
- 345
- 2
- 8
- 32
- 
                    1Did you figure this out? I have the same issue. – Feb 01 '21 at 22:47
3 Answers
93
            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
 
    
    
        Justin
        
- 1,318
- 9
- 12
- 
                    2"The `swiftlint autocorrect` command is no longer available. Please use `swiftlint --fix` instead." (`swiftlint` version 0.47.1) – marc-medley Jul 01 '22 at 05:15
14
            
            
        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
 
    
    
        Manish Agrawal
        
- 10,958
- 6
- 44
- 76
- 
                    1While this works, I would recommend against this approach. Funky symlinks on your local system cannot be checked in to source-control, and are a manual step which are prone to breaking from system to system. – orion elenzil Sep 21 '22 at 16:41
0
            
            
        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
 
    
    
        Bhavnish
        
- 42
- 1
- 6