From a1197695fc7dd7750001dc60853fd19f162dc69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Wed, 28 Feb 2024 08:37:26 -0800 Subject: [PATCH] fix(iOS) [0.74]: properly warn about createRootViewWithBridge (#43146) Summary: This PR fixes an issue that `_logWarnIfCreateRootViewWithBridgeIsOverridden` was called in wrong place. Assuming user overrides this method and call to `[super]`: ```objc - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps { UIView *view = [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps]; view.backgroundColor = [UIColor redColor]; return view; } ``` This method still wasn't called in bridgeless (and not showing the error). Checking if user overrides this method in `appDidFinishWithLaunching` works every time ![simulator_screenshot_0E22557C-CE37-4617-A25A-F39A6ED4D3D0](https://github.com/facebook/react-native/assets/52801365/d7865f37-32f0-40ad-a252-74ab7c5b7757) ## Changelog: [IOS] [FIXED] - Properly warn about `createRootViewWithBridge` being deprecated Pull Request resolved: https://github.com/facebook/react-native/pull/43146 Test Plan: Check if warning is shown when message is overridden Reviewed By: huntie Differential Revision: D54303506 Pulled By: cipolleschi fbshipit-source-id: cf30555c791493f28b3015a189cf93b60cace8f8 --- packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index fc186499b8e3bc..6c464725d87d8d 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -118,6 +118,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( } rootView = [self createRootViewWithBridge:self.bridge moduleName:self.moduleName initProps:initProps]; } + [self _logWarnIfCreateRootViewWithBridgeIsOverridden]; [self customizeRootView:(RCTRootView *)rootView]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [self createRootViewController]; @@ -160,7 +161,6 @@ - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps { - [self _logWarnIfCreateRootViewWithBridgeIsOverridden]; BOOL enableFabric = self.fabricEnabled; UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);