After upgrading to RN v0.43 and CodePush v2.0.2-beta, I can no longer run iOS release builds. This happened on my own app, as well as the example app in this repo. It works fine on Android.
Whether running from Xcode or using run-ios, the app fails in [ensureBinaryBundleExists] with the error
React Native doesn't generate your app's JS bundle by default when deploying to the simulator. If you'd like to test CodePush using the simulator, you can do one of three things depending on your React Native version and/or preferred workflow:
1. Update your AppDelegate.m file to load the JS bundle from the packager instead of from CodePush. You can still test your CodePush update experience using this workflow (debug builds only).
2. Force the JS bundle to be generated in simulator builds by removing the if block that echoes "Skipping bundling for Simulator platform" in the "node_modules/react-native/packager/react-native-xcode.sh" file.
3. Deploy a release build to the simulator, which unlike debug builds, will generate the JS bundle (React Native >=0.22.0 only).
I've done thing 1 exactly as suggested in the README, tried thing 2 to no avail, and thing 3 does not make sense because this is a release build. It used to work successfully for the past several months, until now.
yarn install; react-native run-ios)2.0.2-beta0.43.316.0.0-alpha.6Hello @cooperka.
Due to you use debug scheme for building the project (Product-> Scheme -> Edit Scheme -> Run -> Build Configuration) you need to inject the following logic before you init codePush in AppDelegate.m:
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#else
jsCodeLocation = [CodePush bundleURL];
#endif
We should add this to our example app too, thanks for pointing at this.
Another option should be to use Release Build Configuration instead of Debug.
Please verify if it helps and let us know the results.
Hi @max-mironov, as mentioned in the original description I have tried both of those solutions already. Here's my code:
NSURL *jsCodeLocation;
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#else
jsCodeLocation = [CodePush bundleURL];
#endif
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MyApp"
initialProperties:nil
launchOptions:launchOptions];
It works in Debug, but not in Release.
It turns out this was a false-positive error message from CodePush; there was an error in the transpiled bundle.js that caused React Native to fail to load the source code, causing [self binaryBundleURL] to be false.
Maybe the debug message could be made more clear, or only output in Debug builds? I'd be happy to make a PR if you have a preference.
Thank you for the description of the issue @cooperka, and apologies for the false positive error message! It covers the majority of scenarios, but I can see that we missed something - if you were able to add on a small note at the end addressing your situation, we would be happy to look at the PR.
Hi @cooperka - do you have a chance to look at this? We can also enhance the error message - just let us know what description you believe fits best for your case. Please let us know what you think about this.
Thanks for the reminder, @max-mironov. I haven't quite gotten around to this yet, but I was thinking of just disabling the error message for Release builds since the message doesn't apply (in fact suggestion #3 is to use a release build). I think it's a pretty rare problem though (only occurs if you have a syntax error in the transpiled code), so I haven't really prioritized the fix 馃樋
@cooperka - thanks for this. Can you please have a look at this PR: https://github.com/Microsoft/react-native-code-push/pull/811 and let us know if we are good here or should change error message to be more descriptive.
Closing this as PR has been merged.