react-native: Fail to build using Xcode 12 Beta 4
Description
When I try to build a project with Xcode 12 Beta 4 to test iOS14, I got a plenty of Undefined symbols for architecture x86_64. Every time I build the app, the list of errors is changed. Native libraries fail to recognize base React classes.
React Native version:
info Fetching system and libraries information...
(node:16978) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
System:
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 558.54 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.3.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /Users/laigorols/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: iOS 14.0, DriverKit 20.0, macOS 11.0, tvOS 14.0, watchOS 7.0
Android SDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 12.0/12A8179i - /usr/bin/xcodebuild
Languages:
Java: 12.0.1 - /usr/bin/javac
Python: 2.7.16 - /Users/laigorols/.pyenv/shims/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.2 => 0.63.2
npmGlobalPackages:
*react-native*: Not Found
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Add native dependencies to
package.json; - Install dependencies using
yarn install; - Run
pod installin ios folder to auto link native dependencies; - Try to run application in simulator using Xcode;
Expected Results
Application is successfully installed and executed in simulator.
Snack, code example, screenshot, or link to a repository:
Xcode error log: Build Xcode12ReactNativeSample_2020-08-12T17-06-23.txt
Github repository with sample: https://github.com/igoriols/xcode12reactnativesample
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 52 (26 by maintainers)
Commits related to this issue
- fix: add React-Core to podspec for Xcode 12 compatibility https://github.com/facebook/react-native/issues/29633 — committed to radko93/react-native-webview by radko93 4 years ago
- fix: Xcode 12 compatibility Latest Xcode 12 fails to build without a module to depend on `React-Core` directly hence this change is necessary for all native modules on iOS. This change requires React... — committed to standardnotes/react-native-sodium by radko93 4 years ago
- Update react-native-agora.podspec Xcode 12 compatibility. Ref: https://github.com/facebook/react-native/issues/29633#issuecomment-694187116 — committed to jaykhandelwal/react-native-agora by jaykhandelwal 4 years ago
- Podspec: Depend on React-Core instead of React Fixes Xcode 12 compatibility (see: https://github.com/facebook/react-native/issues/29633#issuecomment-694187116) — committed to mrousavy/react-native-blurhash by mrousavy 4 years ago
- Podspec: Depend on React-Core instead of React From now on native modules should only depend on `React-Core` instead of `React`. See: https://github.com/facebook/react-native/issues/29633 — committed to wix/react-native-navigation by mrousavy 4 years ago
- Fix Xcode 12 Compatibility Xcode 12 (released on Sept 16) fails to build without the module being liked to React-Core directly. This change is needed for React Native 0.60.2 or newer for iOS Ref: ht... — committed to jaykhandelwal/react-native-notifications by jaykhandelwal 4 years ago
- fix: change pod dependency After XCode 12 release, the previous implementation was breaking. See https://github.com/facebook/react-native/issues/29633#issuecomment-694187116 — committed to bamlab/react-native-image-resizer by PierreCapo 4 years ago
- fix: change pod dependency (#258) After XCode 12 release, the previous implementation was breaking. See https://github.com/facebook/react-native/issues/29633#issuecomment-694187116 — committed to bamlab/react-native-image-resizer by deleted user 4 years ago
- fix(ios): depend directly on React-Core instead of transitively via React necessary for Xcode 12 build compatibility reference: https://github.com/facebook/react-native/issues/29633 — committed to mikehardy/react-native-update-apk by mikehardy 4 years ago
- fix: Xcode 12 compatibility The latest Xcode 12 fails to build when a module does not depend on `React-Core` directly. This change is necessary for all native modules on iOS. For details please see: ... — committed to Fetten/react-native-masked-view by Fetten 4 years ago
- fix: Xcode 12 compatibility The latest Xcode 12 fails to build when a module does not depend on `React-Core` directly. This change is necessary for all native modules on iOS. For details please see: ... — committed to Fetten/react-native-linear-gradient by Fetten 4 years ago
- fix: Xcode 12 compatibility The latest Xcode 12 fails to build when a module does not depend on `React-Core` directly. This change is necessary for all native modules on iOS. For details please see: ... — committed to Fetten/react-native-permissions by Fetten 4 years ago
- fix: Xcode 12 compatibility The latest Xcode 12 fails to build when a module does not depend on `React-Core` directly. This change is necessary for all native modules on iOS. For details please see: ... — committed to Fetten/react-native-image-picker by Fetten 4 years ago
- fix: Xcode 12 compatibility The latest Xcode 12 fails to build when a module does not depend on `React-Core` directly. This change is necessary for all native modules on iOS. For details please see: ... — committed to Fetten/react-native-picker by Fetten 4 years ago
- feat: Xcode 12 compatibility (#142) The latest Xcode 12 fails to build when a module does not depend on `React-Core` directly. This change is necessary for all native modules on iOS. For details plea... — committed to react-native-picker/picker by Fetten 4 years ago
- chore(release): 1.8.0 [skip ci] # [1.8.0](https://github.com/react-native-community/react-native-picker/compare/v1.7.1...v1.8.0) (2020-09-19) ### Features * Xcode 12 compatibility ([#142](https://g... — committed to react-native-picker/picker by semantic-release-bot 4 years ago
- fix: Xcode 12 compatibility (#1429) The latest Xcode 12 fails to build when a module does not depend on `React-Core` directly. This change is necessary for all native modules on iOS. For details plea... — committed to react-native-image-picker/react-native-image-picker by Fetten 4 years ago
- fix: Xcode 12 compatibility For more information: https://github.com/facebook/react-native/issues/29633#issuecomment-694187116 — committed to react-native-google-signin/google-signin by jozan 4 years ago
- [CocoaPods] Make React-Core compatible with Swift modules Related to https://github.com/facebook/react-native/issues/29633 — committed to alloy/react-native by alloy 4 years ago
- Fix React dependency to enable XCode 12 build https://github.com/facebook/react-native/issues/29633#issuecomment-694187116 — committed to harunsmrkovic/react-native-giphy-ui by harunsmrkovic 4 years ago
Hi all š
Unfortunately I only just became aware of this ticket, so my apologies for the delay but thanks for the workarounds and the patience! š
I tried the reproduction kindly provided by @igoriols and was able to determine the problem. The issue is that all the podspecs of these libraries that fail to link depend on the
Reactpod, which is in fact really only an umbrella dependency for pure JS applications to depend on, whereas the native APIs that these libraries rely on actually reside in theReact-Corepod.This means that they technically were always incorrectāconceptually one should always explicitly depend on the lib that provides the APIs you rely on, rather than relying on transitive dependenciesābut it seems like in previous Xcode versions the build system worked differently and having the transitive dependencies around just happened to work š¤·āāļø
The correct fix going forward is for all these libs to update their dependency from
ReacttoReact-Core:To unblock yourself you could use something like patch-package to temporarily hot-patch the podspecs you need, but it would be really great for the longer term and the community if you could also submit that change upstream to the respective library š (See for example this react-native-webview pull-request.)
Hi, my Xcode got updated to 12 today š
How do you know what the affected targets are?
Update: issue still exists with Xcode 12 Beta 5. Also, upgrading Cocoapods to 1.10 beta doesnāt help.
The issue seems to be related with React Nativeās Auto-linking. So building a React Native only project wonāt be affected, but if you bring in some libraries like react-native-safe-area or react-native-webview , the compiling fails.
After comparing the affected targets with other React Native targets, I found that
React.frameworkwas missing in theLink Binary With Librariesbuild phase for those auto-linked pods.So I came up with a Workaround: Add a
post_installin Podfile to manually add theReact.frameworkback. (Update: Please notice that I used:generate_multiple_pod_projects => truein my Podfile.)Still, hope this could be fixed on React Native side.
@mrousavy Ok, created the PR to update React-Core https://github.com/facebook/react-native/pull/29995
I fixed the issue by updating all the libs and by creating an empty swift file within the project.
Thanks @radko93 for jumping on all of these! š
@xiao99xiao thanks for the workaround, itās compiling for me now.
@igoriols you might need to update the script a bit as per your use case.
Pasting the script that worked for me:
You can use this script to fix the issue for all of your node modules: https://gist.github.com/HosseinRashno/4786b289356ad9840b6c087ce8191fe4
Link to StackOverflow: https://stackoverflow.com/a/65218722/4497248
Edit: And of course, you have to
delete the pod folderandpod install, and then in xCodeclean the projectand build it again.We ran into the same, having to manage multiple repoās which different sets of dependencies with mixed versions, we had to manually patch many dependencies. So we ended up writing a little script that does the work for us, itās a bit of a hack, but it works for us š¤·āāļø . Will share it here, but no guarantees it will work in your case as well. Place in the the root dir of your project, and run it on postinstall.
Without a doubt š
Note that even though a GM exists, the beta is still needed for macOS 11/arm64.
@mikehardy I couldnāt reproduce the issue all the time, after a lot of cleaning and rebuilding I once had the error that a firebase package couldnāt be built (thatās why Iāve created the PR over there)
help me a lot, thanks
Letās try to keep this issue on topic, as itās lengthy enough as it is and otherwise people might miss the important bits when they come looking for solutions.
Also, @mikehardy I think the firebase app package version hasnāt been updated:
@mikehardy, not all modules are affected, I pointed out that I didnāt test react-native-device-info yet. If youāre sure it (youāve cleaned the project etc) works you can dismiss this PR.
Hi there! I have a bunch of modules like that should be affected (like react-native-device-info which @radko93 just PRd, thanks!).
I just updated to Xcode12. Iām trying the examples to demonstrate the problem.
My build is working fine? How do I demonstrate this failure? The example apps appear to work so which makes me uncomfortable, normally I like to have the first step of a PR verification be ādemonstrate the problemā š¤
Thanks to @xiao99xiao and @naveen-c , I was able to use the following script to solve my problem with the workaround:
I had to add
yoga.frameworktoreact-native-safe-area-context, also. šHi @xiao99xiao , thanks for your help. Just let me see if I understand it right: this script adds
React.frameworktoLink Binary With Librariesbuild phase for each native library pods (the ones Auto-linked) that uses react-native. Is that right?I used the following script:
The
Undefined symbols for architecture x86_64errors persists and the script didnāt addReact.frameworkinLink Binary With Libraries. Did I do something wrong when I used your script?I donāt know if it means something for the issue, but there was a
React (pods)inDependenciessection already. I thought the libs were importing reactās dependencies this way: