microsoft / react-native-macos

A framework for building native macOS apps with React.
https://microsoft.github.io/react-native-windows/
MIT License
3.49k stars 135 forks source link

[0.72] Cherry Pick: Remove uses of `butter/function.h` #2046

Closed Saadnajmi closed 8 months ago

Saadnajmi commented 8 months ago

Please select one of the following

Summary:

Intermittently, I will get the following error in various React Native macOS projects:

.../Pods/Headers/Public/ReactCommon/react/bridging/Base.h:13:10 'butter/function.h' file not found

This doesn't happen in RNTester, and doesn't seem to reproduce in CI pipelines building the same projects. My theory is because our 0.72-stable has a lot of cherry-picked fabric related changes from 0.73 that might cause the issue, and/or RN-Tester sets some compiler flag that downstream projects don't. Regardless, it's enough of an annoyance that I want to fix it.

Butter is a cpp "shim" layer that lets you replace uses of Function in libraries like Folly with your own (example, Mso::Functor). See the commit that introduces butter/function: https://github.com/facebook/react-native/commit/6c315de2260318134ebfbe84aac65ae08085c198

However, it seems over time two things have happened:

  1. Meta would like to reduce usage of Folly in React Native, and thus..
  2. Meta has been replacing uses of the butter shim layer with the c++ standard library.

To both of those points, see https://github.com/facebook/react-native/commit/4d85e112a33518f64f7d76c904884ba5abc2587b. This change was introduced in 0.73+, and I am cherry-picking it down to 0.72 for our fork.

Changelog:

[GENERAL] [FIXED] - Remove uses of butter/function.h

Test Plan:

CI should pass.