I have a custom "Run Script" step in my Xcode projects Build Phases which does the following:
#!/bin/zsh
set -e
# move to the node project directory
cd ~/my-node-project
# build js project
npm run build
echo "[BuildPhase] finished!"
However, it seems that the Shell environment Xcode has access to doesn't include several environment variables such as the paths to node
, asdf
or even homebrew
.
I have changed the shell to use zsh which is the default on my machine, however, even when I attempt to source my ~/.zshrc
in the custom build phase, I get the following issue:
/Users/asleepace/.zshrc:52: command not found: brew
I have a custom "Run Script" step in my Xcode projects Build Phases which does the following:
#!/bin/zsh
set -e
# move to the node project directory
cd ~/my-node-project
# build js project
npm run build
echo "[BuildPhase] finished!"
However, it seems that the Shell environment Xcode has access to doesn't include several environment variables such as the paths to node
, asdf
or even homebrew
.
I have changed the shell to use zsh which is the default on my machine, however, even when I attempt to source my ~/.zshrc
in the custom build phase, I get the following issue:
/Users/asleepace/.zshrc:52: command not found: brew
Share
Improve this question
asked Mar 17 at 23:54
AsleepaceAsleepace
3,7652 gold badges27 silver badges39 bronze badges
1 Answer
Reset to default 0The solution was to add homebrew to the PATH adding the following at the top of the file:
export PATH="$PATH:/opt/homebrew/bin"
Once that was added, the source ~/.zshrc
command succeeded, here is the full script for context:
#!/bin/zsh
set -e
# add homebrew location to path (location may vary)
export PATH="$PATH:/opt/homebrew/bin"
# source zshrc file (could also be ~/.bashrc)
source ~/.zshrc
# move to project directory
cd ~/my-node-project
echo "[BuildPhase] building application..."
# build project
npx vite build
echo "[BuildPhase] finished!"