Skip to content

Commit 40a8434

Browse files
Job Vranishfacebook-github-bot
Job Vranish
authored andcommittedJan 26, 2018
Removed use of xip.io, as it's not needed.
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/` <!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html Happy contributing! --> Background: The automatic IP detection feature (introduced [here](#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](#13326), which helps. However, I don’t believe the use of `xip.io` is needed at all. Based on [this comment](8c29a52#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](#8091) [Added option to disable xip #13326](#13326) <!-- Help reviewers and the release process by writing your own release notes **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [-{Component}-] [ INTERNAL ] [ ENHANCEMENT ] [ {File} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| [CATEGORY] [TYPE] [LOCATION] - MESSAGE EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> [INTERNAL] [BUGFIX] [./scripts] - Removed use of xip.io Closes #17642 Differential Revision: D6814609 Pulled By: hramos fbshipit-source-id: f2faebd6a29b0b211d78cdfe8e195906307ab552
1 parent 46fd864 commit 40a8434

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed
 

‎scripts/react-native-xcode.sh

-8
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,11 @@ set -x
9595
DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH
9696

9797
if [[ "$CONFIGURATION" = "Debug" && ! "$PLATFORM_NAME" == *simulator ]]; then
98-
PLISTBUDDY='/usr/libexec/PlistBuddy'
99-
PLIST=$TARGET_BUILD_DIR/$INFOPLIST_PATH
10098
IP=$(ipconfig getifaddr en0)
10199
if [ -z "$IP" ]; then
102100
IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\ -f2 | awk 'NR==1{print $1}')
103101
fi
104102

105-
if [ -z ${DISABLE_XIP+x} ]; then
106-
IP="$IP.xip.io"
107-
fi
108-
109-
$PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:localhost:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" "$PLIST"
110-
$PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:$IP:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" "$PLIST"
111103
echo "$IP" > "$DEST/ip.txt"
112104
fi
113105

1 commit comments

Comments
 (1)

wadim commented on Jun 21, 2018

@wadim

Would be great to update the docs on this too, @jvranish

Please sign in to comment.