From be66dd355cdc3e2e70585f97f67601e8505d11ea Mon Sep 17 00:00:00 2001 From: Keaton Greve Date: Mon, 20 Aug 2018 18:28:52 -0700 Subject: [PATCH] Generate ip.txt before SKIP_BUNDLING check (#20554) Summary: Fixes #20553. Re-applies the change as described in https://github.com/facebook/react-native/pull/16533, which was closed for being stale. Thanks to emusgrave for the original PR/change. Pull Request resolved: https://github.com/facebook/react-native/pull/20554 Differential Revision: D9414933 Pulled By: hramos fbshipit-source-id: 8ebca57e32b905c4ecfd661524ca415f51162545 --- scripts/react-native-xcode.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index 88ea804a806324..b5402f6e78da17 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -8,6 +8,20 @@ # This script is supposed to be invoked as part of Xcode build process # and relies on environment variables (including PWD) set by Xcode +# Print commands before executing them (useful for troubleshooting) +set -x +DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH + +# Enables iOS devices to get the IP address of the machine running Metro Bundler +if [[ "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then + IP=$(ipconfig getifaddr en0) + if [ -z "$IP" ]; then + IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\ -f2 | awk 'NR==1{print $1}') + fi + + echo "$IP" > "$DEST/ip.txt" +fi + if [[ "$SKIP_BUNDLING" ]]; then echo "SKIP_BUNDLING enabled; skipping." exit 0; @@ -90,19 +104,6 @@ nodejs_not_found() type $NODE_BINARY >/dev/null 2>&1 || nodejs_not_found -# Print commands before executing them (useful for troubleshooting) -set -x -DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH - -if [[ "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then - IP=$(ipconfig getifaddr en0) - if [ -z "$IP" ]; then - IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\ -f2 | awk 'NR==1{print $1}') - fi - - echo "$IP" > "$DEST/ip.txt" -fi - BUNDLE_FILE="$DEST/main.jsbundle" $NODE_BINARY "$CLI_PATH" $BUNDLE_COMMAND \