diff --git a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.h b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.h index 96fd88a7afd..50e2e0bf166 100644 --- a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.h +++ b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.h @@ -48,10 +48,11 @@ typedef std::shared_ptr (^RCTHostJSEngineProv */ @interface RCTHost : NSObject -- (instancetype)initWithHostDelegate:(id)hostDelegate - turboModuleManagerDelegate:(id)turboModuleManagerDelegate - bindingsInstallFunc:(facebook::react::ReactInstance::BindingsInstallFunc)bindingsInstallFunc - jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider NS_DESIGNATED_INITIALIZER FB_OBJC_DIRECT; +- (instancetype)initWithBundleURL:(NSURL *)bundleURL + hostDelegate:(id)hostDelegate + turboModuleManagerDelegate:(id)turboModuleManagerDelegate + bindingsInstallFunc:(facebook::react::ReactInstance::BindingsInstallFunc)bindingsInstallFunc + jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider NS_DESIGNATED_INITIALIZER FB_OBJC_DIRECT; /** * This function initializes an RCTInstance if one does not yet exist. This function is currently only called on the diff --git a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.mm b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.mm index 97e9c1be4f9..7ab1b72146c 100644 --- a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.mm +++ b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.mm @@ -52,10 +52,11 @@ using namespace facebook::react; Host initialization should not be resource intensive. A host may be created before any intention of using React Native has been expressed. */ -- (instancetype)initWithHostDelegate:(id)hostDelegate - turboModuleManagerDelegate:(id)turboModuleManagerDelegate - bindingsInstallFunc:(facebook::react::ReactInstance::BindingsInstallFunc)bindingsInstallFunc - jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider +- (instancetype)initWithBundleURL:(NSURL *)bundleURL + hostDelegate:(id)hostDelegate + turboModuleManagerDelegate:(id)turboModuleManagerDelegate + bindingsInstallFunc:(facebook::react::ReactInstance::BindingsInstallFunc)bindingsInstallFunc + jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider { if (self = [super init]) { _hostDelegate = hostDelegate; @@ -78,7 +79,7 @@ using namespace facebook::react; return strongSelf->_bundleURL; }; - auto bundleURLSetter = ^(NSURL *bundleURL) { + auto bundleURLSetter = ^(NSURL *bundleURL_) { [weakSelf _setBundleURL:bundleURL]; }; @@ -92,6 +93,7 @@ using namespace facebook::react; return [strongSelf->_hostDelegate getBundleURL]; }; + [self _setBundleURL:bundleURL]; [_bundleManager setBridgelessBundleURLGetter:bundleURLGetter andSetter:bundleURLSetter andDefaultGetter:defaultBundleURLGetter]; @@ -140,7 +142,6 @@ using namespace facebook::react; @"RCTHost should not be creating a new instance if one already exists. This implies there is a bug with how/when this method is being called."); [_instance invalidate]; } - [self _setBundleURL:[_hostDelegate getBundleURL]]; _instance = [[RCTInstance alloc] initWithDelegate:self jsEngineInstance:[self _provideJSEngine] bundleManager:_bundleManager diff --git a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.h b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.h index 5006e14ef0c..da866c481a9 100644 --- a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.h +++ b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.h @@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN RCT_EXTERN_C_BEGIN RCTHost *RCTHostCreateDefault( + NSURL *bundleURL, id hostDelegate, id turboModuleManagerDelegate, RCTHostJSEngineProvider jsEngineProvider); diff --git a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.mm b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.mm index 31d1af728d2..3b928e3332e 100644 --- a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.mm +++ b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.mm @@ -8,12 +8,14 @@ #import "RCTHostCreationHelpers.h" RCTHost *RCTHostCreateDefault( + NSURL *bundleURL, id hostDelegate, id turboModuleManagerDelegate, RCTHostJSEngineProvider jsEngineProvider) { - return [[RCTHost alloc] initWithHostDelegate:hostDelegate - turboModuleManagerDelegate:turboModuleManagerDelegate - bindingsInstallFunc:nullptr - jsEngineProvider:jsEngineProvider]; + return [[RCTHost alloc] initWithBundleURL:bundleURL + hostDelegate:hostDelegate + turboModuleManagerDelegate:turboModuleManagerDelegate + bindingsInstallFunc:nullptr + jsEngineProvider:jsEngineProvider]; }