From a42fd8c16bc6b71a21cdf367974f786fc26c6e7a Mon Sep 17 00:00:00 2001 From: Hilke Heremans Date: Mon, 10 Apr 2017 10:47:29 -0700 Subject: [PATCH] Ignore all loopback addresses for ip detection Summary: There is a bug with IP detection on Macs that have (1) multiple ethernet interfaces, (2) are using the second or third interface as their primary connection and (3) have extra loopback IPs configured (for example when running OpenVPN, running some Docker configurations or other more exotic applications). In those cases, automatic IP detection will falsely detect the IP as something like `127.94.0.1`, which will make it impossible to run debug builds from a physical device. The underlying network configurations looks something similar to this (irrelevant parts omitted): ``` lo0: flags=8049 mtu 16384 options=1203 inet 127.0.0.1 netmask 0xff000000 inet 127.94.0.1 netmask 0xff000000 nd6 options=201 en0: flags=8863 mtu 1500 options=10b ether xx:xx:xx:xx:xx:xx nd6 options=201 media: autoselect Closes https://github.com/facebook/react-native/pull/13415 Differential Revision: D4859654 Pulled By: javache fbshipit-source-id: 3c5d06201c48a2dfe1c274ff433423e5d7f2cded --- packages/metro-bundler/react-native-xcode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/metro-bundler/react-native-xcode.sh b/packages/metro-bundler/react-native-xcode.sh index 1a1c3660..dc83971f 100755 --- a/packages/metro-bundler/react-native-xcode.sh +++ b/packages/metro-bundler/react-native-xcode.sh @@ -78,7 +78,7 @@ if [[ "$CONFIGURATION" = "Debug" && ! "$PLATFORM_NAME" == *simulator ]]; then PLIST=$TARGET_BUILD_DIR/$INFOPLIST_PATH IP=$(ipconfig getifaddr en0) if [ -z "$IP" ]; then - IP=$(ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d\ -f2 | awk 'NR==1{print $1}') + IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\ -f2 | awk 'NR==1{print $1}') fi if [ -z ${DISABLE_XIP+x} ]; then