From 52efed6437f5caab5b2d511ee0ba95afb0962945 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 5 Oct 2026 03:39:18 -0700 Subject: [PATCH] Disable folly coroutines for library pods in install_modules_dependencies (#58845) Summary: The iOS `react-native-clipboard/clipboard` job in the [nightly tests](https://github.com/react-native-community/nightly-tests/actions/runs/37195709435/job/111417053963) has failed since the `20261003` nightly: ``` Pods/Headers/Public/ReactNativeDependencies/folly/Expected.h:1587:10: fatal error: 'folly/coro/Coroutine.h' file not found ``` Since https://github.com/react/react-native/issues/58711, `TurboModule.h` includes the `React/Bridging.h` umbrella, which includes `Dynamic.h` and therefore `folly/dynamic.h`. So every library that includes `RCTTurboModule.h` (for example through its codegen spec header) now compiles folly headers. Some libraries set their own folly flags. Clipboard, for example, passes `-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1`. With `FOLLY_NO_CONFIG`, `folly-config.h` is skipped and `FOLLY_CFG_NO_COROUTINES` is never defined. Under C++20, folly then turns on coroutines and includes `folly/coro/Coroutine.h`, which the prebuilt `ReactNativeDependencies` doesn't ship. This change makes `install_modules_dependencies` always append `-DFOLLY_CFG_NO_COROUTINES=1` to the library's compiler flags. React Native's own pods already use this flag (see `Helpers::Constants.folly_config`). ## Changelog: [IOS] [FIXED] - Fix `'folly/coro/Coroutine.h' file not found` in libraries that set their own folly compiler flags Pull Request resolved: https://github.com/react/react-native/pull/58845 Test Plan: - Updated `new_architecture-test.rb` to assert that `spec.compiler_flags` contains `-DFOLLY_CFG_NO_COROUTINES=1`, both when new arch is enabled and when it is disabled. - Ran the CocoaPods Ruby tests locally, excluding `spm-test.rb` because the `cocoapods` gem isn't available outside bundler in my environment: `ruby -Itest all_tests.rb -n /installModulesDependencies/`. The new `compiler_flags` assertions pass. In my local Ruby 3.4 environment the same 28 tests fail on both `main` and this branch, including a `HEADER_SEARCH_PATHS` assertion right after the new ones. That's an environment issue, not this change; relying on CI for the full suite. - I didn't run the nightly-tests clipboard job against this change. It should pass once a nightly includes this fix. Reviewed By: vzaidman Differential Revision: D123393629 Pulled By: cipolleschi fbshipit-source-id: b0ce442e9ded7842e1137b8379efb021f36d9919 --- .../scripts/cocoapods/__tests__/new_architecture-test.rb | 3 ++- packages/react-native/scripts/cocoapods/new_architecture.rb | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb b/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb index 9cb7ca410bf..fe6277b3105 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb @@ -130,7 +130,7 @@ class NewArchitectureTests < Test::Unit::TestCase NewArchitectureHelper.install_modules_dependencies(spec, true, '2024.10.14.00') # Assert - assert_equal("-DRCT_NEW_ARCH_ENABLED=1", spec.compiler_flags) + assert_equal("-DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_CFG_NO_COROUTINES=1", spec.compiler_flags) assert_equal( [ "\"$(PODS_ROOT)/Headers/Private/Yoga\"", @@ -206,6 +206,7 @@ class NewArchitectureTests < Test::Unit::TestCase # Assert assert_equal("#{NewArchitectureHelper.folly_compiler_flags}", Helpers::Constants.folly_config[:compiler_flags]) + assert_equal("-DFOLLY_CFG_NO_COROUTINES=1", spec.compiler_flags) assert_equal([*other_flags_arr, '"$(PODS_ROOT)/Headers/Private/Yoga"', '$(PODS_ROOT)/glog', '$(PODS_ROOT)/boost', '$(PODS_ROOT)/DoubleConversion', '$(PODS_ROOT)/fast_float/include', '$(PODS_ROOT)/fmt/include', '$(PODS_ROOT)/SocketRocket', '$(PODS_ROOT)/RCT-Folly'], spec.pod_target_xcconfig["HEADER_SEARCH_PATHS"]) assert_equal("c++20", spec.pod_target_xcconfig["CLANG_CXX_LANGUAGE_STANDARD"]) assert_equal( diff --git a/packages/react-native/scripts/cocoapods/new_architecture.rb b/packages/react-native/scripts/cocoapods/new_architecture.rb index 86fa4d47e92..faf154bc590 100644 --- a/packages/react-native/scripts/cocoapods/new_architecture.rb +++ b/packages/react-native/scripts/cocoapods/new_architecture.rb @@ -107,7 +107,10 @@ class NewArchitectureHelper } end header_search_paths_string = header_search_paths.join(" ") - spec.compiler_flags = compiler_flags.empty? ? self.computeFlags(new_arch_enabled).strip! : "#{compiler_flags} #{self.computeFlags(new_arch_enabled)}" + # Libraries may pass their own folly flags, so always disable folly coroutines: + # ReactNativeDependencies does not ship the folly/coro headers. + module_compiler_flags = "#{self.computeFlags(new_arch_enabled).strip} -DFOLLY_CFG_NO_COROUTINES=1".strip + spec.compiler_flags = compiler_flags.empty? ? module_compiler_flags : "#{compiler_flags} #{module_compiler_flags}" current_config["HEADER_SEARCH_PATHS"] = current_headers.empty? ? header_search_paths_string : "#{current_headers} #{header_search_paths_string}"