New Arch Failure: RCTAppDelegate.bridge Is Permanently Nil, Blocking Subsequent Bundle Loading #308
sohiniacharya-wq
started this conversation in
Deep Dive
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Previously in old architecture to load new bundles dynamically inside an app we were creating an RCTBridge and a RCTRootView with this bridge and creating a rootViewController and assigning the RCTView to that rootViewController and loading that. That was working fine.
But now in new architecture all of that is taken care by dependencyProvider. But the self.bridge after we create the dependencyProvider and call super.application(application, didFinishLaunchingWithOptions: launchOptions) and return that always stays nil.
final class AppDelegate: RCTAppDelegate, ... {
// ...
override func application(...) -> Bool {
// New Arch Configuration (Correctly set BEFORE super)
self.moduleName = AppLaunchConstants.moduleName
self.dependencyProvider = RCTAppDependencyProvider()
self.initialProps = [:]
}
// ...
}
So later when I try to this while trying to load a different bundle:
func loadJsBundle(with url: URL) {
guard let app = UIApplication.shared.delegate as? AppDelegate else { return }
let b = RCTBridge(delegate: app, launchOptions: nil)
self.bridge = app.sharedBridge ?? b
notificationCenter.addObserver(self, selector: #selector(bundleDidLoad(:)),
name: .RCTJavaScriptDidLoad, object: b)
notificationCenter.addObserver(self, selector: #selector(bundleDidFail(:)),
name: .RCTJavaScriptDidFailToLoad, object: b)
}
I got error: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DeviceInfo' could not be found. Verify that a module by this name is registered in the native binary.
The reason also I understand. Creation of new RCTBridge(delegate: app, launchOptions: nil) is creating new Turbo module registry. We should be using the bridge of the app delegate and Turbo modules of it. But that is always nil. app.sharedBridge is always nil. So I am unable to load new bundles.
Beta Was this translation helpful? Give feedback.
All reactions