Skip to content

Commit 52efed6

Browse files
cipolleschimeta-codesync[bot]
authored andcommitted
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 #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: #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
1 parent 2a2ccaa commit 52efed6

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def test_installModulesDependencies_whenNewArchEnabledAndNewArchAndNoSearchPaths
130130
NewArchitectureHelper.install_modules_dependencies(spec, true, '2024.10.14.00')
131131

132132
# Assert
133-
assert_equal("-DRCT_NEW_ARCH_ENABLED=1", spec.compiler_flags)
133+
assert_equal("-DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_CFG_NO_COROUTINES=1", spec.compiler_flags)
134134
assert_equal(
135135
[
136136
"\"$(PODS_ROOT)/Headers/Private/Yoga\"",
@@ -206,6 +206,7 @@ def test_installModulesDependencies_whenNewArchDisabledAndSearchPathsAndCompiler
206206

207207
# Assert
208208
assert_equal("#{NewArchitectureHelper.folly_compiler_flags}", Helpers::Constants.folly_config[:compiler_flags])
209+
assert_equal("-DFOLLY_CFG_NO_COROUTINES=1", spec.compiler_flags)
209210
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"])
210211
assert_equal("c++20", spec.pod_target_xcconfig["CLANG_CXX_LANGUAGE_STANDARD"])
211212
assert_equal(

‎packages/react-native/scripts/cocoapods/new_architecture.rb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ def self.install_modules_dependencies(spec, new_arch_enabled, folly_version = He
107107
}
108108
end
109109
header_search_paths_string = header_search_paths.join(" ")
110-
spec.compiler_flags = compiler_flags.empty? ? self.computeFlags(new_arch_enabled).strip! : "#{compiler_flags} #{self.computeFlags(new_arch_enabled)}"
110+
# Libraries may pass their own folly flags, so always disable folly coroutines:
111+
# ReactNativeDependencies does not ship the folly/coro headers.
112+
module_compiler_flags = "#{self.computeFlags(new_arch_enabled).strip} -DFOLLY_CFG_NO_COROUTINES=1".strip
113+
spec.compiler_flags = compiler_flags.empty? ? module_compiler_flags : "#{compiler_flags} #{module_compiler_flags}"
111114
current_config["HEADER_SEARCH_PATHS"] = current_headers.empty? ?
112115
header_search_paths_string :
113116
"#{current_headers} #{header_search_paths_string}"

0 commit comments

Comments
 (0)