discussions-and-proposals
discussions-and-proposals copied to clipboard
Ability to specify a custom IP for 'react-native run-ios' command
Introduction
The current implementation of react-native-xcode.sh script is limited to the first available network interface (see code snippet):
# Enables iOS devices to get the IP address of the machine running Metro
if [[ "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then
for num in 0 1 2 3 4 5 6 7 8; do
IP=$(ipconfig getifaddr en${num})
if [ ! -z "$IP" ]; then
break
fi
done
if [ -z "$IP" ]; then
IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | grep -v ' 169.254.' |cut -d\ -f2 | awk 'NR==1{print $1}')
fi
echo "$IP" > "$DEST/ip.txt"
fi
This makes it quite difficult to get Metro Server to run on the correct interface with a custom network configuration.
Details
The above code is executed in xCode during Bundle React Native code and images build phase:
export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh
Discussion points
Option of allowing IP= to be customized would make it greatly easier for developers to run Metro Server with react-native run-ios command. I personally find it troublesome to get Metro Server to work with my setup and this feature would be greatly appreciated
I think it'd be a good idea, but it's likely that you'd have to do the PR yourself to enable this. It'd probably the fastest way to get someone to review and give you feedback
I think it'd be a good idea, but it's likely that you'd have to do the PR yourself to enable this. It'd probably the fastest way to get someone to review and give you feedback
Indeed 👍 I believe is a good addition. A PR on this is most likely going to be reviewed/merged.