From 9ae3714f4bebdd2bcab4d7fdbf23acebdc5ed2ba Mon Sep 17 00:00:00 2001 From: Geoffrey Goh Date: Wed, 24 Feb 2016 03:11:08 -0800 Subject: [PATCH] Create offline package if not running in "Debug" config Summary:**Problem**: As seen in https://github.com/facebook/react-native/issues/5820, many devs are confused by the fact that the offline bundle is not generated when running against the simulator, even when running in the "Release" configuration which is supposed to mimic "production" scenarios. This pull request is a small change that fixes https://github.com/facebook/react-native/issues/5820 by updating the `react-native-xcode.sh` shell script to still generate the ofline bundle during Release configuration. It also updates `AppDelegate.m` to better document this behaviour in the comments so as to avoid any surprises. **Test plan**: This is a simple change, the two tests done were 1. In a new React Native project, verify that an offline build is not generated when running against the simulator in "Debug" configuration as per normal. 2. Change to a "Release" configuration via Product > Scheme > Edit Scheme in XCode, then verify that the project runs with the offline build generated. ![screen shot 2016-02 Closes https://github.com/facebook/react-native/pull/6119 Differential Revision: D2970755 Pulled By: javache fb-gh-sync-id: 64f658512869c73aa19286ca1e3dc6e31b5ac617 shipit-source-id: 64f658512869c73aa19286ca1e3dc6e31b5ac617 --- .../generator-ios/templates/app/AppDelegate.m | 4 +++- packager/react-native-xcode.sh | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/local-cli/generator-ios/templates/app/AppDelegate.m b/local-cli/generator-ios/templates/app/AppDelegate.m index 6cf213bd4..909092b9c 100644 --- a/local-cli/generator-ios/templates/app/AppDelegate.m +++ b/local-cli/generator-ios/templates/app/AppDelegate.m @@ -36,7 +36,9 @@ /** * OPTION 2 * Load from pre-bundled file on disk. The static bundle is automatically - * generated by "Bundle React Native code and images" build step. + * generated by the "Bundle React Native code and images" build step when + * running the project on an actual device or running the project on the + * simulator in the "Release" build configuration. */ // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; diff --git a/packager/react-native-xcode.sh b/packager/react-native-xcode.sh index 66ecea854..9e6ffbe43 100755 --- a/packager/react-native-xcode.sh +++ b/packager/react-native-xcode.sh @@ -10,15 +10,15 @@ # This script is supposed to be invoked as part of Xcode build process # and relies on environment variables (including PWD) set by Xcode -# There is no point in creating an offline package for simulator builds -# because the packager is supposed to be running during development anyways -if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then - echo "Skipping bundling for Simulator platform" - exit 0; -fi - case "$CONFIGURATION" in Debug) + # 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; + fi + DEV=true ;; "")