react-native: 0.19 - Unable to run in simulator using main.jsbundle - Unable to execute JS call: __fbBatchedBridge is undefined

I’ve recently upgraded to 0.19 and my app runs fine if I am getting the javascript from the react packager using this line in AppDelegate.m:

jsCodeLocation = [NSURL URLWithString:@"http://192.168.1.10:8081/index.ios.bundle?platform=ios&dev=true"];

(note that I have to use my IP address here and have that IP added as an App Transport Security Setting exception, I guess because I use google auth in my app).

But to let others run my app through Xcode, while we are developing the backend, I was creating the main.jsbundle using this command:

curl http://localhost:8081/index.ios.bundle -o main.jsbundle

And this worked fine with 0.18.1, but after upgrading to 0.19, if I run the the simulator or even on the device whith this line in AppDelegate.m:

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

I get the error: Unable to execute JS call: __fbBatchedBride is undefined

I do get this message repeated in the Xcode console.

I’ve read all stackoverflows and issues that match __fbBatchedBridge is undefined and haven’t come up with an answer. I guess dropping back to 0.18.1 and that didn’t solve the problem (see comments below).

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I ran into a similar issue with the __fbBatchedBridge error for different reasons (I accidentally deleted the reference to main.jsbundle from my Xcode project). I believe the error arises when React can’t find the main.jsbundle file in your app’s main bundle at runtime.

I was able to resolve it as follows:

  1. Use the react-native command line to regenerate the main.jsbundle file (note that this command must be run from the root of your react native project). $ react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle
  2. Add the generated main.jsbundle back into the Xcode project: File -> Add Files to Project. (After doing this you should verify that main.jsbundle appears in the files listed in the “Copy Bundle Resources” build phase.)
  3. Re-build and voila!

Moreover this is NOT documented on the docs for running in offline mode. I literally spent one day trying to arrive at this issue.

I don’t think this issue is resolved even with react-native version 23 and 25. How is this marked closed? I cannot still run emulator with offline bundle and keep getting fbBatchedBridge undefined error. Can someone re-open this and investigate please?

For those like me who may spend a day figuring out why they have the error “Unable to execute JS call: __fbBatchedBridge is undefined” after they upgrade to OS x El Capitan 10.11 with react-native 0.29 When upgrading, the owner of usr/local changes and then the watchman can’t run so you have to exec a chown on that folder so that it belongs to you. Once done, you will be able, in the folder of your project, to start again npm and finally to build your app without this error 😉