You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
metro.config.js server config allows for input of port only, it would be great if it could accept host as well, so we could dynamically overwrite this with an IP address:
Use case:
When deploying to a physical device, the device connects to metro over WiFi. This means that offline app functionality cannot be tested without disconnecting from metro. With a host override in the config, we could dynamically populate this with the device USB interface IP, routing the connection through USB and allowing the device WiFi to be switched off without getting disconnected from our metro server.
The react native debug interface allows you to do this manually in the app through the Configure Bundler menu so it should be fairly simple?
The text was updated successfully, but these errors were encountered:
react-native-xcode.sh attempts to grab the USB IP Address so that physical device can connect to metro over USB. However your script only checks a few network interface numbers, up to en8, then falls back to computer LAN IP:
Enables iOS devices to get the IP address of the machine running Metro
if [[ ! "$SKIP_BUNDLING_METRO_IP" && "$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"
When I connect my iPhone via USB to my macbook, it's under en12, could you add more numbers to that for loop? :D
I will close this issue here and raise it against react-native itself
Do you want to request a feature or report a bug?
Request a feature
What is the current behavior?
metro.config.js server config allows for input of
port
only, it would be great if it could accepthost
as well, so we could dynamically overwrite this with an IP address:defaultConfig.server = { port: 8081, host: 192.168.0.234 }
Use case:
When deploying to a physical device, the device connects to metro over WiFi. This means that offline app functionality cannot be tested without disconnecting from metro. With a
host
override in the config, we could dynamically populate this with the device USB interface IP, routing the connection through USB and allowing the device WiFi to be switched off without getting disconnected from our metro server.The react native debug interface allows you to do this manually in the app through the
Configure Bundler
menu so it should be fairly simple?The text was updated successfully, but these errors were encountered: