From 5eb25d2186fd94128ec2ae74fec02429da969e63 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 30 Dec 2022 03:53:39 -0800 Subject: [PATCH] Fix build errors when inheriting RCTAppDelegate in Swift modules (#35661) Summary: When inheriting `RCTAppDelegate` in a module with swift code, the compiler will have a build error when it goes through module headers. because swift does not support cxx headers. we found this issue when we try to inherit the class at Expo's [`EXAppDelegateWrapper`](https://github.com/expo/expo/blob/main/packages/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.h) with RCTAppDelegate in new architecture mode. ## Changelog [IOS][FIXED] - Fix build errors when inheriting RCTAppDelegate in Swift modules Pull Request resolved: https://github.com/facebook/react-native/pull/35661 Test Plan: - ci passed - tested with expo's setup: https://github.com/expo/expo/pull/20470 Reviewed By: rshest Differential Revision: D42293851 Pulled By: cipolleschi fbshipit-source-id: 8a173279db070cc0008c6f8214093951f504dcc1 --- Libraries/AppDelegate/RCTAppDelegate.h | 16 ++++------------ Libraries/AppDelegate/RCTAppDelegate.mm | 5 ++++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Libraries/AppDelegate/RCTAppDelegate.h b/Libraries/AppDelegate/RCTAppDelegate.h index b8d00bab93e7cd..e4e987ad6f0085 100644 --- a/Libraries/AppDelegate/RCTAppDelegate.h +++ b/Libraries/AppDelegate/RCTAppDelegate.h @@ -9,13 +9,8 @@ #import #import -#if RCT_NEW_ARCH_ENABLED -// When the new architecture is enabled, the RCTAppDelegate imports some additional headers -#import -#import -#import - -#endif +@class RCTSurfacePresenterBridgeAdapter; +@class RCTTurboModuleManager; /** * The RCTAppDelegate is an utility class that implements some base configurations for all the React Native apps. @@ -98,11 +93,7 @@ */ - (UIViewController *)createRootViewController; -@end - #if RCT_NEW_ARCH_ENABLED -/// Extension that makes the RCTAppDelegate conform to New Architecture delegates -@interface RCTAppDelegate () /// The TurboModule manager @property (nonatomic, strong) RCTTurboModuleManager *turboModuleManager; @@ -126,5 +117,6 @@ /// @return: `true` if the Fabric Renderer is enabled. Otherwise, it returns `false`. - (BOOL)fabricEnabled; -@end #endif + +@end diff --git a/Libraries/AppDelegate/RCTAppDelegate.mm b/Libraries/AppDelegate/RCTAppDelegate.mm index 39b29792245fa3..c498409d051514 100644 --- a/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/Libraries/AppDelegate/RCTAppDelegate.mm @@ -11,13 +11,16 @@ #if RCT_NEW_ARCH_ENABLED #import +#import #import #import +#import +#import #import static NSString *const kRNConcurrentRoot = @"concurrentRoot"; -@interface RCTAppDelegate () { +@interface RCTAppDelegate () { std::shared_ptr _reactNativeConfig; facebook::react::ContextContainer::Shared _contextContainer; }