Skip to content

Commit

Permalink
Added option to disable xip
Browse files Browse the repository at this point in the history
Summary:
When running an app on a real iPhone in debug mode, I occasionally get issues when trying to load the js bundle and I suspect the issue is with xip.io (and it doesn't look like I'm the only one: facebook#12786 facebook#9688 (comment)). So I've added the ability to optionally disable the use of xip.io if an env variable `DISABLE_XIP` is set.

Add `export DISABLE_XIP=true` to the `Bundle React Native code and images` build phase. Run the app on a real iPhone and ensure that it can load the JS bundle from the host computers IP.
Closes facebook#13326

Differential Revision: D4855719

Pulled By: ericvicenti

fbshipit-source-id: cb2e91291acadaa78ea302800b55c2e5388f6380
  • Loading branch information
Jonathan Kim authored and facebook-github-bot committed Apr 8, 2017
1 parent 263f40a commit 3d3cd86
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packager/react-native-xcode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ if [[ "$CONFIGURATION" = "Debug" && ! "$PLATFORM_NAME" == *simulator ]]; then
if [ -z "$IP" ]; then
IP=$(ifconfig | grep 'inet ' | grep -v 127.0.0.1 | 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.xip.io:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" "$PLIST"
echo "$IP.xip.io" > "$DEST/ip.txt"
$PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:$IP:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" "$PLIST"
echo "$IP" > "$DEST/ip.txt"
fi

BUNDLE_FILE="$DEST/main.jsbundle"
Expand Down

0 comments on commit 3d3cd86

Please sign in to comment.