From cf61ca90025ccfefcb470e998f84bbbe90d3e88e Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Wed, 21 Oct 2015 18:42:08 -0700 Subject: [PATCH] Generate bundle and assets when building via Xcode Summary: This integrates React Native into Xcode's build process, which lets us automatically handle bundling and packaging image assets. Tested the script via https://github.com/frantic/ReactNativeAssetsExample Loaded from packager: screen shot 2015-10-19 at 3 11 12 pm Loaded from offline bundle: screen shot 2015-10-19 at 3 10 58 pm Android: screen shot 2015-10-19 at 3 11 20 pm Closes https://github.com/facebook/react-native/pull/3523 Reviewed By: mkonicek Differential Revision: D2557923 Pulled By: frantic fb-gh-sync-id: 19957e255993696e793b0162662772efd89f5c1a --- react-native-xcode.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 react-native-xcode.sh diff --git a/react-native-xcode.sh b/react-native-xcode.sh new file mode 100755 index 00000000..844788f1 --- /dev/null +++ b/react-native-xcode.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Copyright (c) 2015-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +# Bundle React Native app's code and image assets. +# This script is supposed to be invoked as part of Xcode build process +# and relies on envoronment variables (including PWD) set by Xcode + +case "$CONFIGURATION" in + Debug) + DEV=true + ;; + Release) + DEV=false + ;; + "") + echo "$0 must be invoked by Xcode" + exit 1 + ;; + *) + echo "Unsupported value of \$CONFIGURATION=$CONFIGURATION" + exit 1 + ;; +esac + +# Xcode project file for React Native apps is located in ios/ subfolder +cd .. + +set -x +DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH + +react-native bundle \ + --entry-file index.ios.js \ + --platform ios \ + --dev $DEV \ + --bundle-output "$DEST/main.jsbundle" \ + --assets-dest "$DEST"