From 7c953698b41af7187504fa56a9a7c943ae724cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Wed, 6 Mar 2024 06:51:31 -0800 Subject: [PATCH] Allow importing RCTAppDelegate in Swift (#43339) Summary: This PR fixes importing RCTAppDelegate, cleans up the imports, and properly sets the background color for bridgeless mode when using `RCTRootViewFactory`. The issue with importing to Swift was that `RCTTurboModuleManager` has C++ in headers which caused Swift to error out. bypass-github-export-checks ## Changelog: [IOS] [FIXED] - Allow importing RCTAppDelegate in Swift [INTERNAL] [REMOVED] - Remove unnecessary imports in AppDelegate [INTERNAL] [FIXED] - Properly set background color for bridgeless Pull Request resolved: https://github.com/facebook/react-native/pull/43339 Test Plan: - CI Green - Check if background color is correct Reviewed By: dmytrorykun Differential Revision: D54584489 Pulled By: cipolleschi fbshipit-source-id: cb4b947ca9d0f375b1852dbf5a7d889e920562f7 --- .../AppDelegate/RCTAppDelegate+Protected.h | 4 ++++ .../Libraries/AppDelegate/RCTAppDelegate.mm | 15 +-------------- .../Libraries/AppDelegate/RCTRootViewFactory.mm | 1 + 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate+Protected.h b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate+Protected.h index e74c9c8b43207d..2321b43c4da971 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate+Protected.h +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate+Protected.h @@ -5,8 +5,12 @@ * LICENSE file in the root directory of this source tree. */ +#if defined(__cplusplus) + #import #import "RCTAppDelegate.h" @interface RCTAppDelegate () @end + +#endif diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index f4ea71c1c896b8..64b9ccceca897a 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -7,13 +7,12 @@ #import "RCTAppDelegate.h" #import -#import #import #import #import #import +#import #import -#import #import "RCTAppDelegate+Protected.h" #import "RCTAppSetupUtils.h" @@ -22,26 +21,14 @@ #else #import #endif -#import #import #import -#import -#import -#import -#import #if USE_HERMES #import #else #import #endif -#import -#import -#import -#import #import -#import -#import -#import @interface RCTAppDelegate () @end diff --git a/packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm b/packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm index e8ebdefba1dc7e..c71ea624423433 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm @@ -131,6 +131,7 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName initWithSurface:surface sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact]; + surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor]; return surfaceHostingProxyRootView; }