Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode build rules script "command not found" on M1

I have a project that runs some utility I've installed using homebrew on one of its build rules.

On my M1 mac, homebrew is installed on /opt/homebrew/bin.

I have eval "$(/opt/homebrew/bin/brew shellenv)" present in my ~/.zprofile file, but it seems like Xcode doesn't respect that (or maybe overrides it?).

When trying to evaluate the PATH variable during Xcode run script command I get the following:

PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

For clearance, this is the phase I was running, under Build rules. Image showing the script i've ran

like image 830
gkpln3 Avatar asked Sep 16 '25 17:09

gkpln3


1 Answers

To fix this the solution for now is adding the these lines to my Xcode run scripts.

if [[ ! $PATH =~ /opt/homebrew/bin: ]] ; then 
PATH=/opt/homebrew/bin/:/opt/homebrew/sbin:${PATH}
fi
like image 68
maninvan Avatar answered Sep 18 '25 11:09

maninvan