In 2022 the default build looks in ios/.xcode.env.local and ios/.xcode.env for environment customizations. The provided .xcode.env has an example enabling nvm and setting NODE_BINARY.
This is configured in Build Phases -> Bundle React Native code and images. The shell script looks as follows circa 10/2022:
set -e
WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"
/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"
The Input Files section for this script has
$(SRCROOT)/.xcode.env.local
$(SRCROOT)/.xcode.env
The default .xcode.env looks like this now:
# This `.xcode.env` file is versioned and is used to source the environment
# used when running script phases inside Xcode.
# To customize your local environment, you can create an `.xcode.env.local`
# file that is not versioned.
# NODE_BINARY variable contains the PATH to the node executable.
#
# Customize the NODE_BINARY variable here.
# For example, to use nvm with brew, add the following line
#. "$(brew --prefix nvm)/nvm.sh" --no-use
export NODE_BINARY=$(command -v node)
To reliably get node set, configure your project properties to the current default values and update one of the two reference env files.
My ios/.xcode.env looks like this:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
export NODE_BINARY=$(command -v node)