facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.16k stars 24.32k forks source link

After upgrading to 0.71.11 Xcode build fails with 'butter/map.h' file not found #38520

Closed yurykorzun closed 7 months ago

yurykorzun commented 1 year ago

Description

After upgrading to 0.71.11 Xcode build fails with 'butter/map.h' file not found

Error is related to an include: #include <butter/map.h>. XCode can't compile React-Codegen pod.

▸ Running script 'Copy generated compatibility header'
▸ Running script 'Copy generated compatibility header'
▸ Compiling FBReactNativeSpec-generated.mm
▸ Compiling FBReactNativeSpecJSI-generated.cpp

❌  ios/Pods/Headers/Public/ReactCommon/react/bridging/Object.h:13:10: 'butter/map.h' file not found

#include <butter/map.h>

This issue was also reported in reanimated repo - https://github.com/software-mansion/react-native-reanimated/issues/3823

It was suggested to delete Pods folder and /ios/build before each build, but it's not an acceptable solution

React Native Version

0.71.11

Output of npx react-native info

System: OS: macOS 12.6.5 CPU: (10) arm64 Apple M1 Pro Memory: 256.14 MB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.20.1 - ~/.nvm/versions/node/v16.20.1/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.1/bin/yarn npm: 8.19.4 - ~/.nvm/versions/node/v16.20.1/bin/npm Watchman: 2023.07.10.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.12.1 SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: API Levels: 25, 28, 29, 30, 31, 32, 33 Build Tools: 28.0.3, 29.0.2, 30.0.0, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0, 33.0.2 System Images: android-28 | Google ARM64-V8a Play ARM 64 v8a, android-29 | Google APIs ARM 64 v8a, android-30 | Google APIs ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-30 | Google Play Intel x86 Atom, android-31 | Google APIs ARM 64 v8a, android-31 | Google APIs Intel x86_64 Atom, android-33 | Google APIs ARM 64 v8a, android-33 | Google Play ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.10121639 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.19 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

  1. npx react-native init TestApp --version 0.71.11
  2. yarn add react-native-reanimated + babel config
  3. npm run ios or build via Xcode in ios/

Snack, code example, screenshot, or link to a repository

https://github.com/mgcrea/react-native-sandbox/tree/reanimated-bug

github-actions[bot] commented 1 year ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.71.12. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
yurykorzun commented 1 year ago

It seems that only React-Fabric pod has a butter subspec https://github.com/facebook/react-native/blob/a6b49a15a0eb9a968631e7c724f5fc318162802f/packages/react-native/ReactCommon/React-Fabric.podspec#L83

By default, Fabric is disabled and butter isn't included. Why the project sometimes compiles if I remove Pods folder and build again, it's a mystery.

yurykorzun commented 1 year ago

Adding a separate podspec for butter solves this issue but causes another one. React-Codegen pod doesn't compile, at least on my M1 Mac.

github-actions[bot] commented 1 year ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
simistern commented 1 year ago

+1 to this issue

rifad4u commented 1 year ago

rm -rf ~/Library/Caches/CocoaPods rm -rf Pods rm -rf ~/Library/Developer/Xcode/DerivedData/* pod deintegrate pod setup pod install

Do these steps and check

yurykorzun commented 1 year ago

rm -rf ~/Library/Caches/CocoaPods rm -rf Pods rm -rf ~/Library/Developer/Xcode/DerivedData/* pod deintegrate pod setup pod install

Do these steps and check

It helps if I do it before every build, but it's not acceptable. I didn't have to do it before the upgrade.

salah-ghanim commented 1 year ago

this doesn't seem to be an issue if the builds dir is cleaned ... ios/build

ZhangTaoK commented 1 year ago

+1 to this issue

Sherlock92 commented 1 year ago

Also experiencing this, cleaning the build doesn't seem to help for me

RaguRam1991 commented 1 year ago

rm -rf ~/Library/Caches/CocoaPods rm -rf Pods rm -rf ~/Library/Developer/Xcode/DerivedData/* pod deintegrate pod setup pod install

Do these steps and check

The Path to iphoneos is not set. Run this on CLI to set it: sudo xcode-select --switch /Applications/Xcode.app

reference > https://stackoverflow.com/a/54072304/10317833

RaguRam1991 commented 1 year ago

still facing the issue

RaguRam1991 commented 1 year ago

try this

https://stackoverflow.com/a/76072343/10317833

moreiraj-ppb commented 1 year ago

+1 with this issue with RN 0.72.3. Only works after run:

cd ios && rm -rf Pods && rm -rf Podfile.lock && rm -rf build && pod cache clean --all && pod install

keerthika-priya commented 11 months ago

Is this going to be resolved anytime soon? Still happening in 0.72.7 @cipolleschi Any idea around this? (Sorry for tagging you but this is a very weird issue)

tempest2023 commented 11 months ago

I got this error two. In a very simple macOS popover demo. Here is how I config my project:

npx react-native@latest init MenuBarApp --template "react-native@^0.72.0"
npx react-native-macos-init
yarn add react-native-menubar-extra

AppDelegate.h

@interface AppDelegate : RCTAppDelegate

@property(nonatomic, strong) NSPopover *popover;
@property(nonatomic, strong) NSStatusItem *statusItem;

@end

AppDelegate.mm

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
/* ... some default code */
// Create React Native rootView
  RCTPlatformView *rootView = [self createRootViewWithBridge:self.bridge moduleName:self.moduleName initProps:self.initialProps];
  NSViewController *viewController = [[NSViewController alloc] init];
  viewController.view = rootView;

  _popover = [[NSPopover alloc] init];
  _popover.contentSize = NSMakeSize(400, 600);
  // Set popover content view as React Native rootView
  _popover.contentViewController = viewController;

  // Expands rootView to Popover arrow.
  if (@available(macOS 14.0, *)) {
    _popover.hasFullSizeContent = YES;
  }
  _statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];

  [_statusItem.button setTitle:@"Menubar app"];
  [_statusItem.button setAction:@selector(toggleMenu:)];
}

And when I click build button in Xcode, it fails with this error: butter/function.h file not found.

Here is how I solve it:

# if you're using ios, then ios/build
rm -rf macos/build
rm -rf Pods
pod install
cipolleschi commented 10 months ago

Hello there, sorry for the late reply, I was off the past days. @keerthika-priya is this issue happening to you in a MacOS app, as it is happening to @tempest2023? If yes, I suggest that you open an issue in the MacOS repo as our CI is working correctly in React Native Core and it could be some specific setup of MacOS.

Otherwise, can you provide a reproducer using this template so I can look into it?

keerthika-priya commented 10 months ago

Hi @cipolleschi It is happening in iOS app for me. This is easily reproducible. Just upgrade to react: 18.2.0, react-native: 0.72.7 and do a pod install. Again do a pod install. Basically, do the pod install 2 times and you should face this issue.

cipolleschi commented 10 months ago

@keerthika-priya thanks for reporting.

Again do a pod install. Basically, do the pod install 2 times and you should face this issue.

Is this happening also for a newly created project? Can you try with

npx react-native@0.72 init New072App --version 0.72 --skip-install
cd New072App
yarn install
cd ios
bundle install
bundle exec pod install
bundle exec pod install

And try to build? If not, I suspect that there is something wrong in your Podfile.

michael2h4ng commented 8 months ago

We faced the same issue, and it turned out we were using react-native-linear-gradient. If you are using the same dependency, try removing it and reinstalling again. In our case, FBReactNativeSpecJSI-generated.cpp no longer shows up.

github-actions[bot] commented 7 months ago

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

cipolleschi commented 7 months ago

Closing, as this was due to libraries or stale pods

deivyrene commented 6 months ago

This solved the problem.

https://github.com/software-mansion/react-native-reanimated/issues/3823#issuecomment-1346687536

suhaask147 commented 5 months ago

In our project we do not use the new arch, so we've made a temporary fix to remove the file that fails to compile from the source files of the pod.

installer.pods_project.targets.each do |target|
  if target.name == 'React-Codegen'
    source_files = target.source_build_phase.files
    source_files.each do |source_file|
      if source_file.display_name == "FBReactNativeSpecJSI-generated.cpp"
        source_files.delete(source_file)
      end
    end
  end
end