Skip to content

Commit b2b23a2

Browse files
malordfacebook-github-bot
authored andcommitted
Check en0..en8 when generating ip.txt for iOS debug builds (#28764)
Summary: When generating ip.txt in an iOS debug build, search en0 through en8 for an IP address rather than only checking en0 and en1. For example, on my Mac, the IP address I needed to use was on en5 and the IP address actually detected was a private network of one of my Parallels virtual machines (interface vnic0). ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Fixed] - Search en0 through en8 for the Metro Bundler's IP address when generating iOS debug builds Pull Request resolved: #28764 Test Plan: Should make no difference to users for whom react-native-xcode.sh already worked. On a Mac with multiple virtual machines installed, should prevent ip.txt getting the private IP address of a virtual machine. Differential Revision: D21280671 Pulled By: shergin fbshipit-source-id: e6fe9c8344146626df96129968981462463201f7
1 parent 423b55b commit b2b23a2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scripts/react-native-xcode.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH
1414

1515
# Enables iOS devices to get the IP address of the machine running Metro
1616
if [[ "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then
17-
IP=$(ipconfig getifaddr en0)
18-
if [[ -z "$IP" || -n "`ifconfig $value | grep 'baseT'`" ]]; then
19-
IP=$(ipconfig getifaddr en1)
20-
fi
17+
for num in 0 1 2 3 4 5 6 7 8; do
18+
IP=$(ipconfig getifaddr en${num})
19+
if [ ! -z "$IP" ]; then
20+
break
21+
fi
22+
done
2123
if [ -z "$IP" ]; then
2224
IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | grep -v ' 169.254.' |cut -d\ -f2 | awk 'NR==1{print $1}')
2325
fi

0 commit comments

Comments
 (0)