@@ -23,12 +23,12 @@ case "$CONFIGURATION" in
2323 ;;
2424esac
2525
26+ # Path to react-native folder inside node_modules
27+ REACT_NATIVE_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
28+
2629# Xcode project file for React Native apps is located in ios/ subfolder
2730cd ..
2831
29- set -x
30- DEST=$CONFIGURATION_BUILD_DIR /$UNLOCALIZED_RESOURCES_FOLDER_PATH
31-
3232# Define NVM_DIR and source the nvm.sh setup script
3333[ -z " $NVM_DIR " ] && export NVM_DIR=" $HOME /.nvm"
3434
@@ -43,10 +43,25 @@ if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
4343 eval " $( $HOME /.nodenv/bin/nodenv init -) "
4444fi
4545
46- # npm global install path may be a non-standard location
47- PATH=" $( npm prefix -g) /bin:$PATH "
46+ [ -z " $NODE_BINARY " ] && export NODE_BINARY=" node"
47+
48+ nodejs_not_found ()
49+ {
50+ echo " error: Can't find '$NODE_BINARY ' binary to build React Native bundle" >&2
51+ echo " If you have non-standard nodejs installation, select your project in Xcode," >&2
52+ echo " find 'Build Phases' - 'Bundle React Native code and images'" >&2
53+ echo " and change NODE_BINARY to absolute path to your node executable" >&2
54+ echo " (you can find it by invoking 'which node' in the terminal)" >&2
55+ exit 2
56+ }
57+
58+ type $NODE_BINARY > /dev/null 2>&1 || nodejs_not_found
59+
60+ # Print commands before executing them (useful for troubleshooting)
61+ set -x
62+ DEST=$CONFIGURATION_BUILD_DIR /$UNLOCALIZED_RESOURCES_FOLDER_PATH
4863
49- react-native bundle \
64+ $NODE_BINARY $REACT_NATIVE_DIR /local-cli/cli.js bundle \
5065 --entry-file index.ios.js \
5166 --platform ios \
5267 --dev $DEV \
0 commit comments