react-native: Build fails due to header files missing when using -fcxx-modules flag (AppDelegate.mm)
Description
I can’t build the iOS project, always get the error <projectpath>/ios/Pods/Headers/Public/Yoga/yoga/YGNode.h:14:10: ‘BitUtils.h’ file not found. I tried cleaning up everything, reinstalling pods with repo update etc. etc., didn’t work…
Version
0.68.1
Output of npx react-native info
info Fetching system and libraries information… System: OS: macOS 12.3.1 CPU: (8) arm64 Apple M1 Memory: 146.02 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.0 - ~/Library/Caches/fnm_multishells/10309_1650316313370/bin/node Yarn: 1.22.15 - ~/Library/Caches/fnm_multishells/10309_1650316313370/bin/yarn npm: 8.7.0 - ~/Library/Caches/fnm_multishells/10309_1650316313370/bin/npm Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild Languages: Java: 11.0.14.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.1 => 0.68.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
I was currently upgrading from 0.66.3 to 0.68.1 and did all the steps in the upgrade helper to do so. Afterwards the build is not working.
Snack, code example, screenshot, or link to a repository

About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 42 (30 by maintainers)
I managed to temporarily fix this by copying the files (which are symbolic links anyway) from
ios/Pods/Headers/Private/Yoga/yoga
toios/Pods/Headers/Public/Yoga/yoga
, started withBitUtils.h
then ended up dragging a few more until it built successfully.For me this started happening (maybe, still have to confirm but 99% sure) after I installed
expo
.Aha! It’s indeed there @cipolleschi 😄 tks. This page should be marketed more because I was not even aware it existed. I guess most of us are using the RNUpgradeHelper and reading what are the warnings there that we should be aware of before migrating to newer versions
Ah I see. Thanks for explaining. @cipolleschi what’s your take here. Perhaps we can clearly mention in the doc that the file should be renamed inside Xcode or there is a way to regenerate the xcodeproj so that the .mm file is picked up.
I’ve created an issue here: https://github.com/Salt-PepperEngineering/react-native-nordic-dfu/issues/14
We could, but right now React Native minimum support is for C++ 17 and Cxx modules are a feature of C++ 20, so we can’t enforce it right now. As soon as Meta decides to move the minimum support to C++ 20, we could plan the work to do so.
In this half I’m doing a bunch of work to ensure that
use_frameworks!
will work. This could bring compatibility with C++ modules also (but I’m not sure about that) or at least move us in the right direction. Unfortunately, the framework is quite big and intricated, so it’s not trivial to support them. This effort requires planned work.You can use the flag on v69+. I’m on latest react native now and it works.
Yep, ideally something like we can clone, install dependencies, build and see it failing! 👍
Given that the expo is highly related to this, we could also ask @Kudo if he has any insight on this.
I was able to solve this by creating an Objective C class with static methods that called to my problematic module (in this case, Iterable), and then importing and calling that from the Objective C++ file.
First, my iOS build was not recognising
AppDelegate.mm
file, like the file name was never changed during the React Native upgrade.I had then to go to XCode and change it there so it would reflect in
project.pbxproj
because XCode was still referencing.m
over.mm
. Probably a thing to add as a tip for the community @cortinico?Now I have the same issue as @WNemencha has with
@import Firebase
, which I changed to#import <Firebase/Firebase.h>
and it worked! thanks for sharing 🙏🏻Hey! Not much help there but, I also have this issue with a different library. I tried adding
-fcxx-modules
flag and yoga was broken as well in the same file. The library in question is quite popular one – Segment Analytics. I was trying to call Segment Track in AppDelegate.mm I think it would fail if I tried to initialise it as well since it depends on the same Header file.Yup that’s correct, you won’t be able to use the New Architecture with
.m
FYI I managed to get the build working again by removing all cpp flags and renaming
AppDelegate.mm
back toAppDelegate.m
. I guess this will break other things in the future (maybe the new arch) but at least I can work with this now.