Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swiftlint can't be found on Apple Silicon xcode

Tags:

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.

like image 312
user Avatar asked Feb 01 '21 11:02

user


People also ask

What is SwiftLint?

SwiftLint is an open-source tool to enforce Swift style and conventions. It is developed by Realm. You can set your coding style rules and force them during development. SwiftLint has a command-line tool, Xcode plugin, AppCode, and Atom integration. So, it always fits your development environment.


1 Answers

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
like image 181
Justin Avatar answered Sep 21 '22 14:09

Justin