react-native-maps: Error on startup on react-native 0.74 Bridgeless New Architecture

Summary

Hi,

While testing the Bridgeless New Architecture of react-native 0.74 I got the following error (NOBRIDGE) ERROR Error: Exception in HostFunction: <unknown> and the following in Xcode SurfaceRegistryBinding::startSurface failed. Global was not installed..

I have ran the entire installation process step by step and the error starts when I add the following to my Podfile:

# React Native Maps dependencies

rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path

The following screenshot is directly after the bundle was successful.

Simulator Screenshot - iPhone 15 Pro - 2024-04-25 at 14 29 38

If I’m doing something incorrect I wouldn’t know where.

Reproducible sample code

Not necessary. It happens before you can even think about implementing a MapView in the App.

Steps to reproduce

Follow the installation instructions on react-native 0.74 with the Bridgeless New Architecture enabled. Once you’re at the following step the error will show itself.

# React Native Maps dependencies

rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path

Expected result

I would like to see the app actually start.

Actual result

Crash on startup

React Native Maps Version

1.14.0

What platforms are you seeing the problem on?

iOS (Google Maps)

React Native Version

0.74.0

What version of Expo are you using?

Not using Expo

Device(s)

iPhone 15 Pro (Simulator)

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 months ago
  • Comments: 16

Commits related to this issue

Most upvoted comments

@mym0404 sure!

  1. I enabled a feature of Xcode breakpoints which is Exception Breakpoints
Screenshot_2024-04-30_at_14 36 05
  1. I run the app and see that the constantsToExport was raising an exception. At this point, I had few ways to go:
  • I tried to replace the [GMSServices openSourceLicenseInfo]; line with an empty string => no crashes and no redboxes
  • I wrapped the [GMSService openSourceLicenseInfo]; in a try-catch block to see the exception
@try {
    license = [GMSServices openSourceLicenseInfo];
  } @catch (NSException *ex) {
    NSLog(@"[GMSServices openSourceLicenseInfo] threw and exception: %@",  ex);
  }

@matt-dalton @mrousavy let’s move the MMKV discussion to the MMKV repo, so we can close this issue for maps.

Hey - I’m seeing the same issue with react-native-mmkv, not sure what exactly is causing this. image

Sorry for missleading @mHvNG I meant to put there these 3 lines.

rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'react-native-maps', :path => rn_maps_path

But now I saw that it doesn’t change anything. And you are right, there’s a crash. Deleting code from appDelegate helped me because I turned off new arch which you are turning on with pod install command.

Unfortunately I don’t know how to fix it or if we are even able to do it. Maybe @brentvatne or @lukmccall are able to help here?

Edit: It’s happening on clean rn 0.74 project with turned on new arch, so it’s quite easy to reproduce

@mateki0 Sadly I don’t have those booleans… My AppDelegate.mm:

#import "AppDelegate.h"
//#import <GoogleMaps/GoogleMaps.h>

#import <React/RCTBundleURLProvider.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//  [GMSServices provideAPIKey:@"API_KEY"]; // add this line using the api key obtained from Google Console
  
  self.moduleName = @"AppName";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
  return [self bundleURL];
}

- (NSURL *)bundleURL
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

It’s basically the generated AppDelegate.mm file from 0.74 plus the code for adding an API key for Google Maps.