Skip to content

Commit 3afef3c

Browse files
Kudofacebook-github-bot
authored andcommitted
Fix React module build error with swift integration on new architecture mode (#34527)
Summary: when integrates with swift, the compiler will build clang module based on the *React-Core-umbrella.h*. however, the include chain reaches some c++ headers that are not available from swift. it will cause build error. ![Screen Shot 2022-08-29 at 8 25 08 PM](https://user-images.githubusercontent.com/46429/187200668-2a1f12c9-61e5-4d8b-9531-69ff5c1a5741.png) this pr adds `#ifdef __cplusplus` guard for it. ## Changelog [iOS] [Fixed] - Fix React module build error with swift integration on new architecture mode Pull Request resolved: #34527 Test Plan: one thing we didn't figure out is that we require reanimated to repro the build error. 1. `npx react-native init RN070 --version 0.70.0-rc.4`. # can also repro this issue on 0.69 2. `cd RN070` 3. `yarn add react-native-reanimated@next` 4. `cd ios && rm -rf Pods build && RCT_NEW_ARCH_ENABLED=1 pod install` 5. add `import React;` in `main.m` for clang module generation ```diff --- a/ios/RN070/main.m +++ b/ios/RN070/main.m @@ -1,5 +1,6 @@ #import <UIKit/UIKit.h> +@import React; #import "AppDelegate.h" int main(int argc, char *argv[]) ``` 6. `yarn ios` Reviewed By: cipolleschi Differential Revision: D39128716 Pulled By: jacdebug fbshipit-source-id: d9e9130f99e3b9e5f7807c475a24cdd84880e720
1 parent b444f0e commit 3afef3c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

React/AppSetup/RCTAppSetupUtils.h

+11-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#import <React/RCTBridge.h>
1010
#import <React/RCTRootView.h>
1111

12+
#ifdef __cplusplus
13+
1214
#if RCT_NEW_ARCH_ENABLED
1315

1416
#ifndef RCT_USE_HERMES
@@ -28,17 +30,19 @@
2830
#import <ReactCommon/RCTTurboModuleManager.h>
2931
#endif
3032

31-
RCT_EXTERN_C_BEGIN
32-
33-
void RCTAppSetupPrepareApp(UIApplication *application);
34-
UIView *RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties);
35-
36-
RCT_EXTERN_C_END
37-
3833
#if RCT_NEW_ARCH_ENABLED
3934
RCT_EXTERN id<RCTTurboModule> RCTAppSetupDefaultModuleFromClass(Class moduleClass);
4035

4136
std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupDefaultJsExecutorFactory(
4237
RCTBridge *bridge,
4338
RCTTurboModuleManager *turboModuleManager);
4439
#endif
40+
41+
#endif // __cplusplus
42+
43+
RCT_EXTERN_C_BEGIN
44+
45+
void RCTAppSetupPrepareApp(UIApplication *application);
46+
UIView *RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties);
47+
48+
RCT_EXTERN_C_END

0 commit comments

Comments
 (0)