Skip to content

Commit

Permalink
Merge pull request #24 from kamal/rn-0.49
Browse files Browse the repository at this point in the history
Pull in latest react-native-xcode.sh from react-native 0.49.3
  • Loading branch information
Kevin Brown authored Oct 19, 2017
2 parents 09e8d28 + c4591e7 commit b137602
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions lib/react-native-xcode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,27 @@

set +x

if [[ "$SKIP_BUNDLING" ]]; then
echo "SKIP_BUNDLING enabled; skipping."
exit 0;
fi

# Enable pattern matching
shopt -s extglob

# And on to your previously scheduled React Native build script programming.
eval 'case "$CONFIGURATION" in
$DEVELOPMENT_BUILD_CONFIGURATIONS)
echo "Debug build!"
# Speed up build times by skipping the creation of the offline package for debug
# builds on the simulator since the packager is supposed to be running anyways.
if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then
echo "Skipping bundling for Simulator platform"
exit 0;
if [[ "$PLATFORM_NAME" == *simulator ]]; then
if [[ "$FORCE_BUNDLING" ]]; then
echo "FORCE_BUNDLING enabled; continuing to bundle."
else
echo "Skipping bundling in Debug for the Simulator (since the packager bundles for you). Use the FORCE_BUNDLING flag to change this behavior."
exit 0;
fi
else
echo "Bundling for physical device. Use the SKIP_BUNDLING flag to change this behavior."
fi
DEV=true
Expand Down Expand Up @@ -54,7 +63,11 @@ cd ..
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

# Define entry file
ENTRY_FILE=${1:-index.ios.js}
if [[ -s "index.ios.js" ]]; then
ENTRY_FILE=${1:-index.ios.js}
else
ENTRY_FILE=${1:-index.js}
fi

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
Expand All @@ -69,6 +82,8 @@ fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"

[ -z "$CLI_PATH" ] && export CLI_PATH="$REACT_NATIVE_DIR/local-cli/cli.js"

nodejs_not_found()
{
echo "error: Can't find '$NODE_BINARY' binary to build React Native bundle" >&2
Expand All @@ -92,11 +107,16 @@ eval 'case "$CONFIGURATION" in
PLIST=$TARGET_BUILD_DIR/$INFOPLIST_PATH
IP=$(ipconfig getifaddr en0)
if [ -z "$IP" ]; then
IP=$(ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d\ -f2 | awk 'NR==1{print $1}')
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.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
esac'

Expand All @@ -107,7 +127,7 @@ fi

BUNDLE_FILE="$DEST/main.jsbundle"

$NODE_BINARY "$REACT_NATIVE_DIR/local-cli/cli.js" bundle \
$NODE_BINARY "$CLI_PATH" bundle \
--entry-file "$ENTRY_FILE" \
--platform ios \
--dev $DEV \
Expand All @@ -120,7 +140,7 @@ $NODE_BINARY "$REACT_NATIVE_DIR/local-cli/cli.js" bundle \
cd "$SCHEMES_MANAGER_DIR/../.."
$NODE_BINARY "$SCHEMES_MANAGER_DIR/index.js" hide-library-schemes

if [[ ! $DEV && ! -f "$BUNDLE_FILE" ]]; then
if [[ $DEV != true && ! -f "$BUNDLE_FILE" ]]; then
echo "error: File $BUNDLE_FILE does not exist. This must be a bug with" >&2
echo "React Native, please report it here: https://github.com/facebook/react-native/issues"
exit 2
Expand Down

0 comments on commit b137602

Please sign in to comment.