Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix React module build error with swift integration on new architecture mode #34527

Closed
wants to merge 1 commit into from

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Aug 29, 2022

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

this pr adds #ifdef __cplusplus guard for it.

Changelog

[iOS] [Fixed] - Fix React module build error with swift integration on new architecture mode

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
--- 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[])
  1. yarn ios

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. p: Expo Partner: Expo Partner labels Aug 29, 2022
@react-native-bot react-native-bot added Bug Platform: iOS iOS applications. labels Aug 29, 2022
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,617,808 -60
android hermes armeabi-v7a 7,032,042 -77
android hermes x86 7,917,891 -41
android hermes x86_64 7,891,512 -35
android jsc arm64-v8a 9,495,229 -54
android jsc armeabi-v7a 8,272,846 -68
android jsc x86 9,433,036 -38
android jsc x86_64 10,026,026 -38

Base commit: a45eeea
Branch: main

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: a45eeea
Branch: main

@Kudo Kudo marked this pull request as ready for review August 29, 2022 14:35
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 29, 2022
@facebook-github-bot
Copy link
Contributor

@jacdebug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @Kudo in 3afef3c.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Aug 30, 2022
dmytrorykun pushed a commit that referenced this pull request Sep 14, 2022
…re 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
Titozzz pushed a commit that referenced this pull request Sep 26, 2022
…re 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Merged This PR has been merged. p: Expo Partner: Expo Partner Platform: iOS iOS applications. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants