Fix AppDelegate not passing props in bridgeless and rename getBundleURL (#41169)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41169

* `initialProperties` should be based on `prepareInitialProps`, not `launchOptions` (which don't seem to have an equivalent in bridgeless)
* `getBundleURL` is not idiomatic Objective-C (eg https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html), so rename to `bundleURL`

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D50595790

fbshipit-source-id: b718ebf2590b1d4512bcbd4846c8d11200f486e4
This commit is contained in:
Pieter De Baets
2023-10-24 04:26:48 -07:00
committed by Facebook GitHub Bot
parent 70acd3f7d9
commit 31cf4c4ead
3 changed files with 8 additions and 9 deletions
@@ -139,7 +139,7 @@
- (BOOL)bridgelessEnabled;
/// Return the bundle URL for the main bundle.
- (NSURL *)getBundleURL;
- (NSURL *)bundleURL;
#endif
@@ -88,7 +88,6 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
RCTAppSetupPrepareApp(application, enableTM);
UIView *rootView;
if (enableBridgeless) {
#if RCT_NEW_ARCH_ENABLED
// Enable native view config interop only if both bridgeless mode and Fabric is enabled.
@@ -101,8 +100,8 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
[self createReactHost];
[self unstable_registerLegacyComponents];
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;
RCTFabricSurface *surface = [_reactHost createSurfaceWithModuleName:self.moduleName
initialProperties:launchOptions];
NSDictionary *initProps = [self prepareInitialProps];
RCTFabricSurface *surface = [_reactHost createSurfaceWithModuleName:self.moduleName initialProperties:initProps];
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView = [[RCTSurfaceHostingProxyRootView alloc]
initWithSurface:surface
@@ -284,14 +283,14 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
- (void)createReactHost
{
__weak __typeof(self) weakSelf = self;
_reactHost = [[RCTHost alloc] initWithBundleURL:[self getBundleURL]
_reactHost = [[RCTHost alloc] initWithBundleURL:[self bundleURL]
hostDelegate:nil
turboModuleManagerDelegate:self
jsEngineProvider:^std::shared_ptr<facebook::react::JSEngineInstance>() {
return [weakSelf createJSEngineInstance];
}];
[_reactHost setBundleURLProvider:^NSURL *() {
return [weakSelf getBundleURL];
return [weakSelf bundleURL];
}];
[_reactHost setContextContainerHandler:self];
[_reactHost start];
@@ -311,9 +310,9 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
}
- (NSURL *)getBundleURL
- (NSURL *)bundleURL
{
[NSException raise:@"RCTAppDelegate::getBundleURL not implemented"
[NSException raise:@"RCTAppDelegate::bundleURL not implemented"
format:@"Subclasses must implement a valid getBundleURL method"];
return nullptr;
}
+1 -1
View File
@@ -127,7 +127,7 @@ NSString *kBundlePath = @"js/RNTesterApp.ios";
}
#endif
- (NSURL *)getBundleURL
- (NSURL *)bundleURL
{
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:kBundlePath];
}