From 98dc7d64238fcc66a2250368b2650f6600531c6b Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 27 Jul 2026 11:40:57 -0700 Subject: [PATCH] Forward host:didInitializeRuntime: callback to user delegate (#57438) Summary: `RCTReactNativeFactory` acts as `RCTHost`'s delegate but did not implement `host:didInitializeRuntime:`, causing the optional callback to never reach the user's `RCTReactNativeFactoryDelegate`. Add the missing forwarding method following the same pattern as `hostDidStart:` so the runtime reference is properly delivered to the user delegate. Fixes https://github.com/react/react-native/issues/57349. ## Changelog: [IOS] [FIXED] - Forward `host:didInitializeRuntime:` callback to user delegate in `RCTReactNativeFactory` Pull Request resolved: https://github.com/react/react-native/pull/57438 Test Plan: 1. Implement `host:didInitializeRuntime:` in a custom `RCTReactNativeFactoryDelegate` subclass (e.g. RNTester's `AppDelegate`) 2. Build and launch the app 3. Verify the callback is invoked and the `jsi::Runtime` reference is received 4. Confirm `hostDidStart:` continues to work as before NOTE: No automated test. This mirrors the existing hostDidStart: forwarding in the same RCTReactNativeFactory, which is also untested. host:didInitializeRuntime: is declared on RCTHostDelegate and inherited by RCTReactNativeFactoryDelegate under optional, and the respondsToSelector: guard makes it a no-op for delegates that don't implement it, so there's no logic to regress. No RCTReactNativeFactory delegate-forwarding test harness exists, so a test would be net-new iOS XCTest scaffolding disproportionate to a one-line forward. Reviewed By: cortinico Differential Revision: D113653288 Pulled By: fabriziocucci fbshipit-source-id: 082bb340cd9d61bc30a10c8a7730eca14f69088e --- .../Libraries/AppDelegate/RCTReactNativeFactory.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm b/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm index a407a722ad5..5282900de5f 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm @@ -212,6 +212,13 @@ using namespace facebook::react; } } +- (void)host:(RCTHost *)host didInitializeRuntime:(facebook::jsi::Runtime &)runtime +{ + if ([_delegate respondsToSelector:@selector(host:didInitializeRuntime:)]) { + [_delegate host:host didInitializeRuntime:runtime]; + } +} + - (NSArray *)unstableModulesRequiringMainQueueSetup { #if RN_DISABLE_OSS_PLUGIN_HEADER