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(build): fixes React-RCTText build with RN 0.69.0 #34064

Closed
wants to merge 1 commit into from

Conversation

ph4r05
Copy link
Contributor

@ph4r05 ph4r05 commented Jun 24, 2022

@facebook-github-bot
Copy link
Contributor

Hi @ph4r05!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jun 24, 2022
@analysis-bot
Copy link

analysis-bot commented Jun 24, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,824,877 -4,671
android hermes armeabi-v7a 7,212,339 -3,906
android hermes x86 8,135,421 -3,988
android hermes x86_64 8,115,888 -4,456
android jsc arm64-v8a 9,691,165 -4,236
android jsc armeabi-v7a 8,447,379 -3,474
android jsc x86 9,642,452 -3,566
android jsc x86_64 10,239,821 -4,005

Base commit: afa5df1
Branch: main

@renchap
Copy link
Contributor

renchap commented Jun 24, 2022

I can confirm it fixes things for me, but I am not sure why the .m files would not be picked by the compiler anymore.
Also this seems to only occur when using some third party libraries (react-native-safe-area-context ?).

I feel like this PR is a workaround the real issue (.m files are no longer picked by the compiler).

If we go with this fix, then the root problem is still present and other packages will need to apply the same fix as the root cause is still here, for example react-native-safe-area-context like in the above referenced comment

@analysis-bot
Copy link

analysis-bot commented Jun 24, 2022

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

Base commit: 7d42106
Branch: main

@facebook-github-bot
Copy link
Contributor

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

Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sending this over @ph4r05
We're going to merge this as it was confirmed as valid by @renchap here #33976 (comment)

I'll defer to @cipolleschi for a follow-up on the iOS side if we need one.

@cortinico
Copy link
Contributor

I can confirm it fixes things for me, but I am not sure why the .m files would not be picked by the compiler anymore.
Also this seems to only occur when using some third party libraries (react-native-safe-area-context ?).

Also as an heads up, this is currently failing to build RN Tester internally with:

CompileC [...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/Objects-normal/x86_64/RCTInputAccessoryShadowView.o /[...]/Libraries/Text/TextInput/RCTInputAccessoryShadowView.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-RCTText' from project 'Pods')
    cd /[...]/packages/rn-tester/Pods
    export LANG\=en_US.US-ASCII
    /usr/local/fbprojects/packages/xcode/217/xcode_13.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -target x86_64-apple-ios12.4-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu11 -fobjc-arc -fmodules -fmodules-cache-path\=/[...]/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/[...]/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -DPOD_CONFIGURATION_DEBUG\=1 -DDEBUG\=1 -DCOCOAPODS\=1 -DOBJC_OLD_DISPATCH_PROTOTYPES\=0 -isysroot /usr/local/fbprojects/packages/xcode/217/xcode_13.3.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.4.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability -fobjc-abi-version\=2 -fobjc-legacy-dispatch -index-store-path /[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Index/DataStore -iquote /[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/React-RCTText-generated-files.hmap -I/[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/React-RCTText-own-target-headers.hmap -I/[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/React-RCTText-all-non-framework-target-headers.hmap -ivfsoverlay /[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/all-product-headers.yaml -iquote /[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/React-RCTText-project-headers.hmap -I/[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Products/Debug-iphonesimulator/React-RCTText/include -I/[...]/packages/rn-tester/Pods/Headers/Private -I/[...]/packages/rn-tester/Pods/Headers/Private/React-RCTText -I/[...]/packages/rn-tester/Pods/Headers/Public -I/[...]/packages/rn-tester/Pods/Headers/Public/DoubleConversion -I/[...]/packages/rn-tester/Pods/Headers/Public/RCT-Folly -I/[...]/packages/rn-tester/Pods/Headers/Public/React-Core -I/[...]/packages/rn-tester/Pods/Headers/Public/React-RCTText -I/[...]/packages/rn-tester/Pods/Headers/Public/React-callinvoker -I/[...]/packages/rn-tester/Pods/Headers/Public/React-cxxreact -I/[...]/packages/rn-tester/Pods/Headers/Public/React-jsi -I/[...]/packages/rn-tester/Pods/Headers/Public/React-jsiexecutor -I/[...]/packages/rn-tester/Pods/Headers/Public/React-jsinspector -I/[...]/packages/rn-tester/Pods/Headers/Public/React-logger -I/[...]/packages/rn-tester/Pods/Headers/Public/React-perflogger -I/[...]/packages/rn-tester/Pods/Headers/Public/React-runtimeexecutor -I/[...]/packages/rn-tester/Pods/Headers/Public/Yoga -I/[...]/packages/rn-tester/Pods/Headers/Public/fmt -I/[...]/packages/rn-tester/Pods/Headers/Public/glog -I/[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/DerivedSources-normal/x86_64 -I/[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/DerivedSources/x86_64 -I/[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/DerivedSources -F/[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Products/Debug-iphonesimulator/React-RCTText -fmodule-map-file\=/[...]/packages/rn-tester/Pods/Headers/Public/React/React-Core.modulemap -fmodule-map-file\=/[...]/packages/rn-tester/Pods/Headers/Public/folly/RCT-Folly.modulemap -fmodule-map-file\=/[...]/packages/rn-tester/Pods/Headers/Public/yoga/Yoga.modulemap -include /[...]/packages/rn-tester/Pods/Target\ Support\ Files/React-RCTText/React-RCTText-prefix.pch -MMD -MT dependencies -MF /[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/Objects-normal/x86_64/RCTInputAccessoryShadowView.d --serialize-diagnostics /[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/Objects-normal/x86_64/RCTInputAccessoryShadowView.dia -c /[...]/Libraries/Text/TextInput/RCTInputAccessoryShadowView.m -o /[...]/Library/Developer/Xcode/DerivedData/RNTesterPods-avhcctdswdycllfjzyasqkbrubnn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTText.build/Objects-normal/x86_64/RCTInputAccessoryShadowView.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/React-RCTText.build/Objects-normal/x86_64/RCTInputAccessoryShadowView.o
error: Build input file cannot be found: '/[...]/Libraries/Text/TextInput/RCTInputAccessoryShadowView.m' (in target 'React-RCTText' from project 'Pods')

@cipolleschi
Copy link
Contributor

Hi @ph4r05 and @renchap. Thanks for opening the PR.
I'm wondering whether this fix is actually required... I run several tests, creating new apps and migrating them from 0.67 to 0.68 and 0.69 and it always built properly.

Could you pleas provide a sample repo with a repro of the issue?
If you are migrating, make sure to follow all the steps in the guide that are shown in the repo above.

I just created an app with 0.69 and tried to build with both the legacy and the New Architecture and it builds without issues and without applying the patch.
Is there some dependencies that trigger the issue?

@renchap
Copy link
Contributor

renchap commented Jun 27, 2022

I just created an app with 0.69 and tried to build with both the legacy and the New Architecture and it builds without issues and without applying the patch.
Is there some dependencies that trigger the issue?

Hi @cipolleschi,

Sorry for not yet providing a sample reproducing the issue, I am in the final steps of releasing an app and did not had time to investigate this as properly as I wanted.

This is most probably only occurring when a dependency is used. In the linked issue (#33976) we noticed that react-native-safe-area-context needed a similar patch, so maybe this is the dependency that triggers this?

@cipolleschi
Copy link
Contributor

@renchap I tried to add the react-native-safe-area-context dependencies to a new app using yarn add react-native-safe-area-context. The dependency has been installed in the node_modules.

Then I tried both to install the pods with the new and the legacy architectures. In both cases i could see the pod in the project and the pod install script reporting this line:

Installing react-native-safe-area-context 4.3.1

In both case, after a clean, the app was building and running.

I don't think we need this fix at all. My best guess is that a step was missing when migrating the app.

@ph4r05
Copy link
Contributor Author

ph4r05 commented Jun 28, 2022

@cipolleschi I am working on the PoC app, I will have it today. I think it has also something to do with Expo modules.

@ph4r05
Copy link
Contributor Author

ph4r05 commented Jun 28, 2022

@cipolleschi this is a minimal PoC that behaves as described in the issue: https://github.com/ph4r05/poc-rn-34064
The reason might be that Expo modules are not fully supporting 0.69.0 right now.

Env:

➜  poc-rn-34064 git:(main) xcodebuild -version
Xcode 13.4.1
Build version 13F100
➜  poc-rn-34064 git:(main) pod --version
1.11.3
➜  poc-rn-34064 git:(main) node --version
v16.13.2
➜  poc-rn-34064 git:(main) npm --version
8.13.0
➜  poc-rn-34064 git:(main) gem --version
3.1.6
➜  poc-rn-34064 git:(main) ruby --version
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-darwin21]

@ph4r05
Copy link
Contributor Author

ph4r05 commented Jun 28, 2022

@renchap pls which react-native version do you use in the project?

@cipolleschi
Copy link
Contributor

RN 0.69.0

@renchap
Copy link
Contributor

renchap commented Jun 28, 2022

@ph4r05 RN 0.69.0.

But I am also using expo (for some Expo modules, not the whole thing), so this could come from Expo indeed.

@cipolleschi
Copy link
Contributor

cipolleschi commented Jun 28, 2022

I'm trying out the PoC

  1. first commit build and run (as expected, being the react-init command)
  2. second commit build and run as well.
  3. third commit fails with the error reported in the PR.

I then tried to isolate which change may generate that:

  • Adding specific version of Flipper (flipper_post_install(installer) is already called by react_native_post_install so I don't think we should invoke it explicitly) -> App builds and run
  • bumping iOS to 15.2 -> App builds and run
  • adding expo to the package.json (yarn install && pod install) -> App builds and run
  • add require_relative '../node_modules/expo/scripts/autolinking' && pod install -> Build fails.

So, there is something in the autolinking file of Expo that generates the failure. I tried to look a little bit further into it and looks like that that file requires another file called autolinking_manager which, in turn, requires some other local files from a cocoapods folder. These files monkey-patch some files from Cocoapods framework, hijacking the Cocoapods execution.

From this investigation, it looks like that it's Expo that is not supporting 0.69 yet and I don't think we have to actually merge this PR into React Native. Instead, we should wait for Expo to properly support this new version.

@Kudo what do you think?

@Kudo
Copy link
Contributor

Kudo commented Jun 28, 2022

for expo to integrate React-Core from swift code, we have some patches for React-Core. sometimes the clang compiler requires the imports to be in correct order. otherwise, it will import to wrong headers and have build errors.

my fix toward the problem is like that, maybe it's lower risk. could you check whether it works for you and makes sense to you?

diff --git a/node_modules/react-native/React/Views/RCTShadowView.h b/node_modules/react-native/React/Views/RCTShadowView.h
index 428d2eb..226672f 100644
--- a/node_modules/react-native/React/Views/RCTShadowView.h
+++ b/node_modules/react-native/React/Views/RCTShadowView.h
@@ -8,6 +8,8 @@
 #import <UIKit/UIKit.h>

 #import <React/RCTComponent.h>
+// Keeps RCTConvert.h here before yoga for clang module to generate correct header imports.
+#import <React/RCTConvert.h>
 #import <React/RCTLayout.h>
 #import <React/RCTRootView.h>
 #import <yoga/Yoga.h>

@ph4r05
Copy link
Contributor Author

ph4r05 commented Jun 28, 2022

@Kudo this worked! Shall I change this PR so it reflects this change?

@Kudo
Copy link
Contributor

Kudo commented Jun 28, 2022

@ph4r05 sure, please update the pr if the change makes sense to you.

@ph4r05
Copy link
Contributor Author

ph4r05 commented Jun 28, 2022

done! Great catch with the order of imports @Kudo !

@Kudo
Copy link
Contributor

Kudo commented Jun 28, 2022

thanks everyone here to fix the issue together 🔥

@facebook-github-bot
Copy link
Contributor

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

@Kudo Kudo mentioned this pull request Jun 28, 2022
4 tasks
Kudo added a commit to expo/expo that referenced this pull request Jun 29, 2022
# Why

for sdk 46
close ENG-5353

# How

- update packages 
  - react -> 18.0.0
  - react-native -> 0.69.0
  - react-dom -> 18.0.0
  - react-native-web -> ~0.18.1
  - react-test-renderer -> ~18.0.0
  - @types/react -> ~18.0.14
  - @types/react-native -> ~0.69.1
- early patch react-native for 0.69.1 fixes
  - facebook/react-native@43f831b
  - facebook/react-native@c2088e1
  - facebook/react-native@f97c6a5
  - facebook/react-native@79baca6
  - facebook/react-native#34064 (comment)
- migrate `expo-template-bare-minimum`, `bare-expo`, `bare-sandbox` to 0.69. reference from https://react-native-community.github.io/upgrade-helper/?from=0.68.1&to=0.69.0
  - also remove the `hermesCommand` because 0.69 uses the builtin hermes-engine
- `expo-av`, `expo-modules-core`, `expo-gl-cpp`: fix android cpp building errors, because 0.69 ships both release and debug aar
- `expo-dev-client`: fix android build error from RedBox package rename
-  `html-elements`: update RNWView where react-native-web removed [the `css` import](necolas/react-native-web@b27c9820)
- `expo`: move Expo.podspec out from ios, because newer [rn-cli removed the `podspecPath` and `project` support](react-native-community/cli@25eec7c#diff-0dddbcedebb33032fcac5991f3dcdfa44157e6ae87afcf3dabcd240a0db09832L58).
- [ ] disable dev-client because the vendored reanimated in dev menu doesn't support 0.69 yet, e.g. `folly_json -> folly_runtime`
- update reanimated and gesture-handler to latest for 0.69 support
- `jest-expo`: update to [fix the deprecated react-native-web jest preset](necolas/react-native-web@9b0c119)
- `NCL`, `home`, patch `react-native-svg`: fix react 18 that [`children` should be explicitly added](https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-typescript-definitions)
- `@expo/cli` fix react-native-web and react-dom version checks

# Test Plan

- android bare-expo smoke test
- ios bare-expo smoke test
- ci passed
  - updates e2e is broken because in the flow the react-native doesn't include 0.69.1 fixes.
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @ph4r05 in 4ea38e1.

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 Jun 29, 2022
fortmarek pushed a commit that referenced this pull request Jun 29, 2022
Summary:
Fixes iOS build for React-RCTText with RN 0.69.0, fixes #33976

PR contains changes from #33976 (comment)

PoC repo: https://github.com/ph4r05/poc-rn-34064

Related issues:
- expo/expo#16283
- #33815
- #33976

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Fix build for React-RCTText

Pull Request resolved: #34064

Reviewed By: cortinico

Differential Revision: D37420163

Pulled By: cipolleschi

fbshipit-source-id: 68a831bce9f449348d13e040a1ba12726a66667d
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. Merged This PR has been merged. Needs: React Native Team Attention 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.

Error : Use of undeclared identifier 'YGValue' when building iOS
9 participants