Skip to content

Commit 5eb25d2

Browse files
Kudofacebook-github-bot
authored andcommitted
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: #35661 Test Plan: - ci passed - tested with expo's setup: expo/expo#20470 Reviewed By: rshest Differential Revision: D42293851 Pulled By: cipolleschi fbshipit-source-id: 8a173279db070cc0008c6f8214093951f504dcc1
1 parent 70d9b56 commit 5eb25d2

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Libraries/AppDelegate/RCTAppDelegate.h

+4-12
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99
#import <React/RCTBridgeDelegate.h>
1010
#import <UIKit/UIKit.h>
1111

12-
#if RCT_NEW_ARCH_ENABLED
13-
// When the new architecture is enabled, the RCTAppDelegate imports some additional headers
14-
#import <React/RCTCxxBridgeDelegate.h>
15-
#import <React/RCTSurfacePresenterBridgeAdapter.h>
16-
#import <ReactCommon/RCTTurboModuleManager.h>
17-
18-
#endif
12+
@class RCTSurfacePresenterBridgeAdapter;
13+
@class RCTTurboModuleManager;
1914

2015
/**
2116
* The RCTAppDelegate is an utility class that implements some base configurations for all the React Native apps.
@@ -98,11 +93,7 @@
9893
*/
9994
- (UIViewController *)createRootViewController;
10095

101-
@end
102-
10396
#if RCT_NEW_ARCH_ENABLED
104-
/// Extension that makes the RCTAppDelegate conform to New Architecture delegates
105-
@interface RCTAppDelegate () <RCTTurboModuleManagerDelegate, RCTCxxBridgeDelegate>
10697

10798
/// The TurboModule manager
10899
@property (nonatomic, strong) RCTTurboModuleManager *turboModuleManager;
@@ -126,5 +117,6 @@
126117
/// @return: `true` if the Fabric Renderer is enabled. Otherwise, it returns `false`.
127118
- (BOOL)fabricEnabled;
128119

129-
@end
130120
#endif
121+
122+
@end

Libraries/AppDelegate/RCTAppDelegate.mm

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111

1212
#if RCT_NEW_ARCH_ENABLED
1313
#import <React/CoreModulesPlugins.h>
14+
#import <React/RCTCxxBridgeDelegate.h>
1415
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
1516
#import <React/RCTSurfacePresenter.h>
17+
#import <React/RCTSurfacePresenterBridgeAdapter.h>
18+
#import <ReactCommon/RCTTurboModuleManager.h>
1619
#import <react/config/ReactNativeConfig.h>
1720

1821
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
1922

20-
@interface RCTAppDelegate () {
23+
@interface RCTAppDelegate () <RCTTurboModuleManagerDelegate, RCTCxxBridgeDelegate> {
2124
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
2225
facebook::react::ContextContainer::Shared _contextContainer;
2326
}

0 commit comments

Comments
 (0)