From 34795cbc36d3f1e511b2b7a0fa9639afe258d7e1 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Tue, 27 Oct 2026 09:09:43 -0700 Subject: [PATCH] Delete dead sourceURLForBridge delegate chain (#59452) Summary: `sourceURLForBridge:` has no callers: the factory reads `bundleURL` directly, and the default delegate's implementations only threw or forwarded to each other. Delete the protocol method with those implementations and the factory's dead configuration assignment. The `RCTJavaScriptLoader.h` import stays: removing it breaks every `RCTBridge.h` importer that uses the loader types. Changelog: [iOS][Removed] - Remove deprecated `RCTBridgeDelegate` `sourceURLForBridge:` Reviewed By: javache Differential Revision: D127294778 Pull Request resolved: https://github.com/react/react-native/pull/59452 --- .../RCTDefaultReactNativeFactoryDelegate.mm | 14 -------------- .../Libraries/AppDelegate/RCTReactNativeFactory.mm | 5 ----- .../Libraries/AppDelegate/RCTRootViewFactory.h | 1 + .../react-native/React/Base/RCTBridgeDelegate.h | 11 ----------- packages/rn-tester/RNTester/SceneDelegate.mm | 5 ----- .../cxx-api/api-snapshots/ReactAppleDebugCxx.api | 1 - .../api-snapshots/ReactAppleFrameworksCxx.api | 1 - .../cxx-api/api-snapshots/ReactAppleReleaseCxx.api | 1 - 8 files changed, 1 insertion(+), 38 deletions(-) diff --git a/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm index d94631a23d8..68c66feb8de 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm @@ -26,13 +26,6 @@ @synthesize dependencyProvider; -- (NSURL *_Nullable)sourceURLForBridge:(nonnull RCTBridge *)bridge -{ - [NSException raise:@"RCTBridgeDelegate::sourceURLForBridge not implemented" - format:@"Subclasses must implement a valid sourceURLForBridge method"]; - return nil; -} - - (UIViewController *)createRootViewController { return [UIViewController new]; @@ -126,11 +119,4 @@ return nullptr; } -- (void)loadSourceForBridge:(RCTBridge *)bridge - onProgress:(RCTSourceLoadProgressBlock)onProgress - onComplete:(RCTSourceLoadBlock)loadCallback -{ - [RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] onProgress:onProgress onComplete:loadCallback]; -} - @end diff --git a/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm b/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm index e4ee18ccb51..deba936037f 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm @@ -295,11 +295,6 @@ static NSDictionary *RCTConvertConnectionOptionsToLaunchOptions(UISceneConnectio [weakSelf.delegate customizeRootView:(RCTRootView *)rootView]; }; - configuration.sourceURLForBridge = ^NSURL *_Nullable(RCTBridge *_Nonnull bridge) - { - return [weakSelf.delegate bundleURL]; - }; - if ([self.delegate respondsToSelector:@selector(extraModulesForBridge:)]) { configuration.extraModulesForBridge = ^NSArray> *_Nonnull(RCTBridge *_Nonnull bridge) { diff --git a/packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.h b/packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.h index 000963c81e1..14334a2c102 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.h +++ b/packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.h @@ -6,6 +6,7 @@ */ #import +#import #import #import #import "RCTJSRuntimeConfiguratorProtocol.h" diff --git a/packages/react-native/React/Base/RCTBridgeDelegate.h b/packages/react-native/React/Base/RCTBridgeDelegate.h index 9e5306f8fc7..d5293d9f9db 100644 --- a/packages/react-native/React/Base/RCTBridgeDelegate.h +++ b/packages/react-native/React/Base/RCTBridgeDelegate.h @@ -13,17 +13,6 @@ NS_ASSUME_NONNULL_BEGIN @protocol RCTBridgeDelegate -#ifndef RCT_REMOVE_LEGACY_ARCH - -/** - * The location of the JavaScript source file. When running from the packager - * this should be an absolute URL, e.g. `http://localhost:8081/index.ios.bundle`. - * When running from a locally bundled JS file, this should be a `file://` url - * pointing to a path inside the app resources, e.g. `file://.../main.jsbundle`. - */ -- (NSURL *__nullable)sourceURLForBridge:(RCTBridge *)bridge - __deprecated_msg("This API will be removed along with the legacy architecture."); -#endif @end NS_ASSUME_NONNULL_END diff --git a/packages/rn-tester/RNTester/SceneDelegate.mm b/packages/rn-tester/RNTester/SceneDelegate.mm index 26c4b217677..bd9635151ca 100644 --- a/packages/rn-tester/RNTester/SceneDelegate.mm +++ b/packages/rn-tester/RNTester/SceneDelegate.mm @@ -89,11 +89,6 @@ static NSString *const kBundlePath = @"js/RNTesterApp.ios"; [RCTLinkingManager scene:scene continueUserActivity:userActivity]; } -- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge -{ - return [self bundleURL]; -} - - (NSURL *)bundleURL { return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:kBundlePath]; diff --git a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api index 1ca098e4b6f..369407ed545 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api @@ -2525,7 +2525,6 @@ protocol RCTBackedTextInputViewProtocol : public UITextInput { } protocol RCTBridgeDelegate : public NSObject { - public virtual NSURL* _Nullable sourceURLForBridge:(RCTBridge* bridge); } protocol RCTBridgeMethod : public NSObject { diff --git a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api index 4d74084f244..1fd4521efc7 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api @@ -2583,7 +2583,6 @@ protocol RCTBackedTextInputViewProtocol : public UITextInput { } protocol RCTBridgeDelegate : public NSObject { - public virtual NSURL* _Nullable sourceURLForBridge:(RCTBridge* bridge); } protocol RCTBridgeMethod : public NSObject { diff --git a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api index 1c4998b3d18..3db0e926dc1 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api @@ -2525,7 +2525,6 @@ protocol RCTBackedTextInputViewProtocol : public UITextInput { } protocol RCTBridgeDelegate : public NSObject { - public virtual NSURL* _Nullable sourceURLForBridge:(RCTBridge* bridge); } protocol RCTBridgeMethod : public NSObject {