From 40a8434bde855ecae42408ec1240622152432de7 Mon Sep 17 00:00:00 2001 From: Job Vranish Date: Thu, 25 Jan 2018 16:39:15 -0800 Subject: [PATCH] Removed use of xip.io, as it's not needed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: By default, when a react-native app launches in development mode on a physical iOS device, it attempts to load the JS bundle from a packager at `http://_your-local-ip-address_.xip.io:8081/`. This change removes the use of `xip.io`, which changes that url to: `http://_your-local-ip-address_:8081/` Background: The automatic IP detection feature (introduced [here](https://github.com/facebook/react-native/pull/8091)) is super handy. However, it’s use of `xip.io` has caused myself and others much grief. Some routers do not allow or have intermittent errors when trying to resolve DNS names to local IP addresses. This prompted the introduction of a [DISABLE_XIP feature](https://github.com/facebook/react-native/pull/13326), which helps. However, I don’t believe the use of `xip.io` is needed at all. Based on [this comment](https://github.com/facebook/react-native/commit/8c29a52c54392ce52148e7d3aa9f835537453aa4#commitcomment-18224788), it appears the original reason for using `xip.io` was to “circumvent the numeric IP address limitation in ATS”. But, the reason you can’t create ATS exceptions for raw IP addresses is that ATS is not enforced for raw IP addresses _at all_. You can read the Apple documentation [here](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html), the relevant portion is: > App Transport Security (ATS) applies only to connections made to public host names. The system does not provide ATS protection to connections made to: > * Internet protocol (IP) addresses > * Unqualified host names > * Local hosts employing the .local top-level domain (TLD) For example, in iOS, if you attempt to make an http request (note: _not_ https) to `http://www.google.com` you will get an error due to ATS. However, you can make the same request to `http://172.217.6.14/` (which for me is the same server) and the request will succeed. And in fact, if an ATS exception _was_ needed, the DISABLE_XIP feature shouldn’t work at all, but it does. In short, using `xip.io` with ATS exceptions is unnecessary, causes some very annoying problems for some people, and I think it should just be removed. Run the app on a physical iOS device and verify that it can load the JS bundle from the host computer's IP. [Implemented automatic IP detection for iOS #8091](https://github.com/facebook/react-native/pull/8091) [Added option to disable xip #13326](https://github.com/facebook/react-native/pull/13326) [INTERNAL] [BUGFIX] [./scripts] - Removed use of xip.io Closes https://github.com/facebook/react-native/pull/17642 Differential Revision: D6814609 Pulled By: hramos fbshipit-source-id: f2faebd6a29b0b211d78cdfe8e195906307ab552 --- scripts/react-native-xcode.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index 3eb9cf7b50c299..2aee5a4d82522d 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -95,19 +95,11 @@ set -x DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH if [[ "$CONFIGURATION" = "Debug" && ! "$PLATFORM_NAME" == *simulator ]]; then - PLISTBUDDY='/usr/libexec/PlistBuddy' - PLIST=$TARGET_BUILD_DIR/$INFOPLIST_PATH IP=$(ipconfig getifaddr en0) if [ -z "$IP" ]; then IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\ -f2 | awk 'NR==1{print $1}') fi - if [ -z ${DISABLE_XIP+x} ]; then - IP="$IP.xip.io" - fi - - $PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:localhost:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" "$PLIST" - $PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:$IP:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" "$PLIST" echo "$IP" > "$DEST/ip.txt" fi