I've recently updated react native to the latest version (as painful as it is), and I'm getting this error. The code compiles fine but as soon as the app runs I receive this.
'RCTAppDelegate::bundleURL not implemented', reason: 'Subclasses must implement a valid getBundleURL method'
Any ideas? Thanks!
I've been through this as well and solved this issue by dividing the sourceURLForBridge method inside the AppDelegate.m into two functions:
If you're using expo it should be:
- (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
}
If you're using plain cli it should be:
- (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
}
This is also how you're AppDelegate looks like, if you create a plain new project - which is always a good reference after updating an old one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With