Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RCTAppDelegate::bundleURL not implemented', reason: 'Subclasses must implement a valid getBundleURL method'

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

like image 567
DaleZA Avatar asked Sep 10 '25 21:09

DaleZA


1 Answers

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
}
like image 175
Tharaka Nuwan Avatar answered Sep 13 '25 09:09

Tharaka Nuwan