skip to Main Content

I am trying to add Expo to a bare React Native project. I have upgraded to RN 0.74.2 and EXPO SDK 51. When I run "npx expo run:ios" the app opens but immediately crashed with the following

Opening org.reactjs.native.example.OnSight on iPhone 15 Pro
[CoreFoundation] *** Terminating app due to uncaught exception ‘RCTAppDelegate::bundleURL not implemented’, reason: ‘Subclasses must implement a valid getBundleURL method’
*** First throw call stack:
(
0 CoreFoundation 0x00000001804ae138 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180087db4 objc_exception_throw + 56
2 CoreFoundation 0x00000001804ae048 -[NSException initWithCoder:] + 0
3 OnSight 0x0000000100a33418 -[RCTAppDelegate bundleURL] + 52
4 OnSight 0x00000001002c2350 -[EXAppDelegateWrapper createRCTRootViewFactory] + 52
5 OnSight 0x0000000100a3270c -[RCTAppDelegate application:didFinishLaunchingWithOptions:] + 176
6 OnSight 0x00000001002c2204 -[EXAppDelegateWrapper application:didFinishLaunchingWithOptions:] + 104
7 OnSight 0x000000010026345c -[AppDelegate application:didFinish<…>

I have deeleted cache, node_modules, yarn.lock, metro cache, Pods and Podfile.lock

2

Answers


  1. I have updated the AppDelegate.mm with the following code and it resolved the issue.

    - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
    {
      return [self bundleURL];
    }
    
    - (NSURL *)bundleURL
    {
    #if DEBUG
      return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"];
    #else
      return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
    #endif
    }
    
    Login or Signup to reply.
  2. #import "AppDelegate.h"
    #import <Firebase.h>
    #import "RNSplashScreen.h"
    #import <React/RCTBundleURLProvider.h>
    #import <React/RCTRootView.h>
    #import <GoogleMaps/GoogleMaps.h>
    
    - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
    {
      return [self getBundleURL];
    }
    
    - (NSURL *)getBundleURL
    {
    #if DEBUG
      return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
    #else
      return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
    #endif
    }
    

    Code inside the AppDelegte.m is like this.When I run it shows as Terminating app due to uncaught exception 'RCTAppDelegate::bundleURL not implemented', reason: 'Subclasses must implement a valid getBundleURL method'

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search