Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build release version of app - __fbBatchedBridge is undefined #5770

Closed
ffxsam opened this issue Feb 5, 2016 · 56 comments
Closed

Can't build release version of app - __fbBatchedBridge is undefined #5770

ffxsam opened this issue Feb 5, 2016 · 56 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ffxsam
Copy link

ffxsam commented Feb 5, 2016

I've got an app ready to go live, but I'm unable to build a release version.

Steps I took:

  1. In Xcode, edited the scheme and set Build Configuration to Release and unchecked "Debug executable."
  2. In Terminal, ran react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --resetCache
  3. Set Xcode build target to Simulator (5s, iOS 9.3) and hit run.

I get the following error:

2016-02-04 18:59:17.582 [error][tid:com.facebook.React.JavaScript] Unable to execute JS call: __fbBatchedBridge is undefined
2016-02-04 18:59:17.585 SydTechEco[76215:10166934] *** Terminating app due to uncaught exception 'RCTFatalException: Unable to execute JS call: __fbBatchedBridge is undefined', reason: 'Unable to execute JS call: __fbBatchedBridge is undefined'
@facebook-github-bot
Copy link
Contributor

Hey ffxsam, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

@ffxsam ffxsam changed the title Can't build release version of app Can't build release version of app - __fbBatchedBridge is undefined Feb 5, 2016
@ffxsam
Copy link
Author

ffxsam commented Feb 5, 2016

The strange thing is, I can build/run a release version on my physical device, but not Simulator.

@stereodenis
Copy link
Contributor

got this on 0.19

@ffxsam
Copy link
Author

ffxsam commented Feb 5, 2016

It also happens on a totally fresh project with literally no code added.

@stereodenis
Copy link
Contributor

when I run react-native run-ios i got this

/bin/sh -c /Users/stereodenis/work/evrone/WTCCEuroSport/ios/build/Build/Intermediates/WTCCEuroSport.build/Debug-iphonesimulator/WTCCEuroSport.build/Script-00DD1BFF1BD5951E006B06BC.sh
Skipping bundling for Simulator platform

@stereodenis
Copy link
Contributor

@javache Why bundling is skipping for Simulator platform?

@javache
Copy link
Member

javache commented Feb 5, 2016

Because on the simulator, you'll use a local packager server to serve up the bundle contents.

@stereodenis
Copy link
Contributor

@javache when I want to try bundled app on simulator — what should I do?

@javache
Copy link
Member

javache commented Feb 5, 2016

You can uncomment these line in react-native-xcode.sh: https://github.com/facebook/react-native/blob/master/packager/react-native-xcode.sh#L15-L18 and make sure your rootview/bridge config points to the right JS file.

@stereodenis
Copy link
Contributor

@javache it's a dirty hack)

@javache
Copy link
Member

javache commented Feb 5, 2016

Yeah, we don't use this system internally, and it's mostly aimed at making this work fast for the default use case. You can always create a copy of this script, modify it and use that copy instead in your xcode project.

@stereodenis
Copy link
Contributor

@javache thanks for advice!

@ffxsam
Copy link
Author

ffxsam commented Feb 5, 2016

Thanks. Commenting out that part of the script worked.

@ffxsam ffxsam closed this as completed Feb 5, 2016
@pedramsaleh
Copy link
Contributor

I got this same error on 0.20.0, and it was because my Appdelegate.m file had the line for running on the simulator uncommented, and I was trying to run on a physical device. I switched back to the other line and it ran fine.

@dorthwein
Copy link

+1 commenting out the lines as @javache pointed out worked for me as well in react 0.20.0

@chetstone
Copy link
Contributor

@javache said:

You can always create a copy of this script, modify it and use that copy instead in your xcode project.

But you can't put your new script anywhere you want:

Error: Cannot find module '/Users/chet/prj/malas/firebase/local-cli/cli.js'

because the script looks for other files relative to where it's located:

REACT_NATIVE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

So your new script still has to live in the same directory in the react-native module, which is another gotcha to watch out for when upgrading react-native.

@miracle2k
Copy link

@chetstone Change that line too; I have my script in the project's ios folder, and I write:

REACT_NATIVE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/node_modules/react-native"

@gre
Copy link
Contributor

gre commented Mar 21, 2016

also fall into this and found out the script is "Skipping bundling for Simulator platform" .. I think it's wrong, you shouldn't prevent us from testing the "bundle" mode on the simulator.

@joostlubach
Copy link

I also think this is wrong. Especially since Facebook (!!) requires a working Simulator version for App Review. It makes much more sense to use Debug / Release configs as a determinator whether a bundled version should be created / used, or whether the local packager should be used.

@ffxsam ffxsam reopened this Mar 21, 2016
@ffxsam
Copy link
Author

ffxsam commented Mar 21, 2016

Nice to see some other voices join in here. I still feel that, out of the box, it should not fail when using bundle mode in the simulator.

@stereodenis
Copy link
Contributor

I hope we will not have to change every time the build options

@gre
Copy link
Contributor

gre commented Mar 21, 2016

I just upgraded to RN 0.22 and this somehow get improved though. Now, the script will only not run if you are not in Debug/Dev mode, which quite make sense because you should run Debug with a dev server and "Release" mode with the bundle mode.
so maybe it makes sense?

@andresn
Copy link

andresn commented Mar 25, 2016

I am now seeing the same as @gre, and the lines from @javache's temp solution are now off, here's the full diff with the improvement (thank you RN team btw!):
9ae3714#diff-e35d320a1bf991537277377d63b968e9

@kwelch
Copy link

kwelch commented Mar 30, 2016

I am still getting this error. I am using RN0.22.

I am NOT using a simulator though, I am using an iPad mini.

I am attempting to "Run" from within XCode, I had done the exact steps as the OP.

UPDATE

The project I was working on did not have the build phase for bundling. I have to refer to the upgrading from 0.13 to 0.14

@idkjs
Copy link

idkjs commented May 28, 2016

+1 on 26.2
Alains-MacBook-Pro:AwesomeProject klik$ nvm alias
default -> node (-> v5.2.0)
node -> stable (-> v5.2.0) (default)
stable -> 5.2 (-> v5.2.0) (default)
iojs -> N/A (default)
Alains-MacBook-Pro:AwesomeProject klik$ watchman version
{
"version": "4.5.0"
}
Alains-MacBook-Pro:AwesomeProject klik$ npm -g react-native-cli -v
3.3.12
Alains-MacBook-Pro:AwesomeProject klik$ react-native -v
react-native-cli: 0.2.0
react-native: 0.26.2

@dlahyani
Copy link

+1 on 0.26.0
The weird thing is that it happens on my mac pro but not on my mack book.
I completely removed node and any installed node modules, removed watchman and reinstalled them back just to make sure I have the same environment on both machines. Same node, npm and watchman version, exact same node modules installed (both globally and locally). And yet on the mac book everything works fine on the mac pro i get this error.

Notice that i also got stack trace in XCode console as soon as the JS bundle is loaded:

2016-06-27 12:35:47.795 [error][tid:com.facebook.react.JavaScript] Error: babelHelpers.typeof is not a function. (In 'babelHelpers.typeof(global)', 'babelHelpers.typeof' is undefined), stack:
  http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:24062:61
  loadModuleImplementation@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:105:8
  guardedLoadModule@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:59:32
  _require@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:43:18
  http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:23176:8
  loadModuleImplementation@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:105:8
  guardedLoadModule@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:52:37
  _require@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:43:18
  global code@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:77564:9


2016-06-27 12:35:47.798 [error][tid:com.facebook.react.JavaScript] Error: Can't find variable: process, stack:
  http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:2287:11
  loadModuleImplementation@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:105:8
  guardedLoadModule@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:59:32
  _require@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:43:18
  http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:1961:20
  loadModuleImplementation@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:105:8
  guardedLoadModule@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:59:32
  _require@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:43:18
  http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:1604:25
  loadModuleImplementation@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:105:8
  guardedLoadModule@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:59:32
  _require@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:43:18
  http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:1434:26
  loadModuleImplementation@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:105:8
  guardedLoadModule@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:59:32
  _require@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:43:18
  http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:1417:23
  loadModuleImplementation@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:105:8
  guardedLoadModule@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:59:32
  _require@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:43:18
  http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:1408:19
  loadModuleImplementation@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:105:8
  guardedLoadModule@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:52:37
  _require@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:43:18
  global code@http://localhost:8081/jssrc/index.ios.bundle?platform=ios&dev=true:77566:9


2016-06-27 12:35:49.637 [fatal][tid:main] Unable to execute JS call: __fbBatchedBridge is undefined

Which makes me suspect Babel...

@evanmrose
Copy link

@dlahyani +1, I'm getting the same error. Have tried numerous fixes.

@justsans
Copy link

justsans commented Jun 27, 2016

Getting the same error on any newly created react-native app without any code changes or when trying to run the examples under react-native/Examples

I am creating react-native apps with the command
react-native init AwesomeApp

node: v6.2.2
npm: 2.15.5
ruby: ruby 2.3.1p112
react-native-cli: 1.0.0
react-native: 0.28.0

Stack trace:
2016-06-27 12:05:50.628 [error][tid:com.facebook.react.JavaScript] Error: babelHelpers.typeof is not a function. (In 'babelHelpers.typeof(global)', 'babelHelpers.typeof' is undefined), stack:
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:23228:61
loadModuleImplementation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:127:8
guardedLoadModule@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:70:32
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:54:18
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:22335:8
loadModuleImplementation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:127:8
guardedLoadModule@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:63:37
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:54:18
global code@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:76191:9
2016-06-27 12:05:50.635 [error][tid:com.facebook.react.JavaScript] Error: Can't find variable: process, stack:
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:2428:11
loadModuleImplementation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:127:8
guardedLoadModule@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:70:32
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:54:18
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:2076:20
loadModuleImplementation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:127:8
guardedLoadModule@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:70:32
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:54:18
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:1711:25
loadModuleImplementation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:127:8
guardedLoadModule@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:70:32
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:54:18
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:1541:26
loadModuleImplementation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:127:8
guardedLoadModule@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:70:32
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:54:18
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:1524:23
loadModuleImplementation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:127:8
guardedLoadModule@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:70:32
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:54:18
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:1474:19
loadModuleImplementation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:127:8
guardedLoadModule@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:63:37
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:54:18
global code@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:76192:9
2016-06-27 12:05:52.453 [fatal][tid:main] Unable to execute JS call: __fbBatchedBridge is undefined

@dlahyani
Copy link

dlahyani commented Jun 27, 2016

@evanmrose @justsans I think i managed to solve this on my mac, it took me the whole day to figure this out.
First of all I added the --reset-cache flag to my 'npm start' script, this caused the project to fail on my mac book as well (previously it was working on my mac book but not on my mac pro).
Secondly I removed the .babelrc file in the root of my project (i.e. the one that resides in the same directory as the package.json). - I think this is the key step in process.
And finally I fixed the version of babel modules and plugins versions to match those used by RN (I am not sure if this one really did change anything). So my package.json looks something like that:

"scripts": {
    "lint": "eslint",
    "start": "node node_modules/react-native/local-cli/cli.js start --reset-cache",
    "test": "mocha --require ./jstestutils/mocha-require --compilers js:babel-core/register --recursive ./jstests"
  },
  "dependencies": {
    "react": "15.0.2",
    "react-native": "0.26.0"
  },
  "devDependencies": {
    "babel-core": "6.6.4",
    "babel-polyfill": "6.6.1",
    "babel-preset-es2015": "6.5.0",
    "babel-preset-react": "6.5.0",
    "babel-preset-react-native": "1.9.0",
    "babel-preset-stage-0": "6.5.0",
    "babel-register": "6.6.0",
    "enzyme": "2.3.0",
    "expect": "1.20.1",
    "mocha": "2.4.5",
    "react-addons-test-utils": "15.0.2",
    "react-dom": "15.0.2",
    "react-native-mock": "0.2.2"
  }

Let me know if it did help you guys.

@sydneyitguy
Copy link

+1 on 0.28.0
It just suddenly happened few minutes ago without any code changes.

@mschipperheyn
Copy link

I've had this shit happen to me several times and it always seemed to suddenly happen. I finally figured out that it had to do with babelrc and certain wrong presets I was loading into the project. #4844 Try going to back to the bare bones babelrc you really really need and remove any babel-presets you're loading into the project.

My .babelrc is this:

{
  "presets": [
    "react-native",
    "react-native-stage-0",
    "react-native-stage-0/decorator-support"
 ]

}

@custam
Copy link

custam commented Jul 9, 2016

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 ;)

@justsans
Copy link

justsans commented Jul 9, 2016

@Gabs24 Could you give more information on the folder you mentioned. Why is the usr/local folder important?. Can you explain which folder you are exactly talking about.

Really appreciate your input as I have been stuck with this issue for a while now.?

@custam
Copy link

custam commented Jul 10, 2016

Sure, just execute this command in your terminal : sudo chown $(USER):admin /usr/local
Indeed you (your user) need to be admin of that folder so that the watchman can run.
That way, the watchman will be able to run for the run-ios command of react native.

@dmr
Copy link

dmr commented Jul 14, 2016

I'm not sure if my case applies here but I had the "__fbBatchedBridge is undefined" issue when I tried to build a production app and the reason was that my "schema" in XCode was set to "Debug". --> Changing to "Release" fixed the issue.

@natdm
Copy link

natdm commented Jul 17, 2016

.25 to .29 - getting this. Can't seem to get it to work with any of the above suggestions. Only breaks on a physical device, not emulator.

@tuneZola
Copy link

Your probably getting this because you are trying to use option 2, bundling in your AppDelegate.m file. You should be using option one when using the simulator, but this all changes for RN .30.

@dmr
Copy link

dmr commented Jul 23, 2016

Cool. When will .30 be ready?

@dmr
Copy link

dmr commented Jul 23, 2016

^^

@tuneZola
Copy link

Its ready now, just make sure you run react-native upgrade

@phil-travelbytes
Copy link

react-native upgrade worked for me.
thanks @tuneZola

@javache
Copy link
Member

javache commented Sep 6, 2016

The deployment issues mentioned in this thread should all be solved, or depend on individual project's configuration. Please open a new issue if the cause of this error message is different.

@javache javache closed this as completed Sep 6, 2016
@worldlyjohn
Copy link

still seeing this with RN 0.33.0 and React 15.3.1

@az-9
Copy link

az-9 commented Mar 30, 2017

My app starting to show this error in the middle of development.
Delete the app from the simulator and run react-native run-ios

@jjant
Copy link

jjant commented Jun 24, 2017

Still seeing this on 0.45.0

@aterribili
Copy link

Still seeing this on 0.46.1

@webjay
Copy link

webjay commented Aug 8, 2017

I'm getting it on 0.47.1

@shuang1026
Copy link

I'm getting it on 0.47.2

@poberwong
Copy link

I'm getting it on 0.50.3

@changran52m
Copy link

+1 same error on 0.51.0

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests