Skip to content

Commit

Permalink
Use main.jsbundle in iOS template for production build (#22531)
Browse files Browse the repository at this point in the history
Summary:
Default HelloWorld template for iOS doesn't make production main.jsbundle. This is little bit confusing in compare with Android building app when everything works one first run.

Make it seamless, reduce confuse.
Based on docs https://facebook.github.io/react-native/docs/running-on-device#3-configure-app-to-use-static-bundle

Fixes #22335
Fixes #18562
Pull Request resolved: #22531

Differential Revision: D13372773

Pulled By: cpojer

fbshipit-source-id: 888c675b7d11b1a323445e092ec9ff83924c42f4
  • Loading branch information
radeno authored and kelset committed Dec 12, 2018
1 parent 3576819 commit 8ba5d4c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion local-cli/templates/HelloWorld/ios/HelloWorld/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
NSURL *jsCodeLocation;

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"HelloWorld"
Expand Down

2 comments on commit 8ba5d4c

@antoinerousseau
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about also including this tip:

if [ "${CONFIGURATION}" == "Debug" ]; then
  export SKIP_BUNDLING=true
 fi

in the .pbxproj by default?

@kelset
Copy link
Contributor

@kelset kelset commented on 8ba5d4c Dec 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antoinerousseau a PR would be the best place to discuss that ☺️

Please sign in to comment.