Expo 46, EAS, react-native-firebase and hermes

I’ve run into an interesting issue attempting to get the latest react-native-firebase working with Expo 46 and EAS. The App would build, install and work locally, but when I cut an internal or store build on EAS it would crash on launch in iOS.

After a lot of trial and error, I created an example repo, and ultimately determined the issue was Hermes on iOS.

As far as I can tell, Hermes does not work with react-native-firebase on 0.69.x and Expo SDK 46. Here is an working example repo without Hermes. If you add jsEngine: "hermes" to app.json, and cut a new build on EAS, the same code base crashes on iOS.

This only happens on EAS builds. It works fine locally, unfortunately, but internal or store builds crash on launch. Android works fine.

package.json

 "expo": "~46.0.16",
 "expo-dev-client": "~1.3.1",
 "expo-build-properties": "~0.3.0",
 "@react-native-firebase/analytics": "^16.2.0",
 "@react-native-firebase/app": "~16.2.0",
 "@react-native-firebase/crashlytics": "^16.2.0",
 "@react-native-firebase/perf": "^16.2.0",
 "react": "18.0.0",
 "react-dom": "18.0.0",
 "react-native": "0.69.6",

app.json

    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ],
      "@react-native-firebase/app",
      "@react-native-firebase/crashlytics",
      "@react-native-firebase/perf"
    ]

This appears to be the crash error:

*** Terminating app due to uncaught exception 'RCTFatalException: Could not get BatchedBridge, make sure your bundle is packaged correctly', reason: 'Could not get BatchedBridge, make sure your bundle is packaged correctly'
*** First throw call stack:
(0x1d71ad288 0x1efedd744 0x10471f5f0 0x1047372bc 0x1047357f8 0x10474a0c4 0x104749e58 0x1d71865a4 0x1d7187500 0x1d711f048 0x1d7132bc8 0x104733078 0x1d897541c 0x2483699ac 0x248368e68)

I posted to a react-native-firebase discussion and the maintainer suggested:

Either the bundle was not compiled + included + archived correctly or Hermes is not able to find it for some reason. Not a react-native-firebase thing I don't think. You might try same with hermes+frameworks + app-with-no-other-modules

Anyone have any ideas why react-native-firebase would work locally on iOS with Hermes, but iOS EAS builds crash on launch? Any suggestions or insight would be greatly appreciated.

Any news?

try doing a release build locally. or maybe you have some environment variables that are different locally vs what you have configured on eas build.

Hey Brent, I just read:

Hermes is supported for apps built with EAS Build. There are no plans to backport support to expo build . Jump to “Limitations”.

Does that mean expo run:ios -d uses the classic build system, and therefore doesn’t use Hermes when enabled in app.json? If so, that explains why it builds and installs locally with expo run:ios -d but not with EAS.

I have confirmed the issue by building locally (eas build -p ios --profile preview --local) with eas-cli, and installing the .ipa on my device through xCode. It crashes immediately on launch just like an EAS build.

The example is app is pretty simple. No env variables. Basic eas.json and app.json. The only change between launch and crash is enabling and disabling Hermes.

I am seeing the same error in the Console.app for the local eas-cli build:

*** Terminating app due to uncaught exception ‘RCTFatalException: Could not get BatchedBridge, make sure your bundle is packaged correctly’, reason: ‘Could not get BatchedBridge, make sure your bundle is packaged correctly’

Any ideas? Things to try, or further debug?

expo run:ios does not use the classic build system, it uses prebuild which is what we use on eas build.

i’d suggest following these instructions locally to narrow down the root cause in your example app

Root cause is this issue: 0.69.4 hermes crashes with use_frameworks! enabled.

expo-dev-client with useFramework static and hermes crashes on iOS launch. In blank expo repo, just using expo-build-properties and “useFrameworks”: “static” with jsEngine hermes, without any other libraries, causes the same crash on iOS launch.

Unfortunately, react-native-firebase >= 15.x. requires static headers because of an underlying change in the firebase SDK. “Unfortunately, you need to use use_frameworks! in your Podfile for react-native-firebase v15+ (which uses firebase-ios-sdk v9+ which brings in this requirement)”

The solution, until this is resolved, is:

  • don’t use hermes, and useFrameworks static with v15+
  • use hermes, but lock react-native-firebase to v14.11.0
2 Likes

Thank you tyrauber your solution seems to work.

Do you know if the expo team is planning to make react-native-firebase >= 15 compatible with expo in the near future ?

Best

My understanding is that this isn’t an Expo issue, but an upstream issue (linked above) in react-native with Hermes compatibility with static frameworks. It’s really unfortunate the google team made this requirement in the base firebase SDK. I am sure there was a reason, but I don’t think the implications were fully thought through. This issue now needs to be resolved by the react-native team.

1 Like

Oh interesting thanks :slight_smile:

I am facing this error while creating a development build using EAS. Did anyone face the same?

Which version of react-native-firebase? Hermes or JSC?

@react-native-firebase/analytics”: “16.4.6”,
@react-native-firebase/app”: “15.4.0”,

From docs:

I didn’t execute “expo prebuild --clean” because I am building the project using EAS. So, I am not sure about Hermes or JSC.

Upgraded to Expo SDK 47, and working fine now.

2 Likes