Skip to content

New Architecture: Folly header errors due to manual compiler flags before install_modules_dependencies #1001

@ChrisWiles

Description

@ChrisWiles

Issue

The session replay package (@datadog/mobile-react-native-session-replay v2.12.1) manually sets Folly compiler flags BEFORE calling install_modules_dependencies, causing build errors with React Native 0.81's precompiled XCFrameworks.

Error

'folly/coro/Coroutine.h' file not found

Current Code

if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
  s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"  # <- Manual Folly flags
  xcconfig.merge!({
    "DEFINES_MODULE" => "YES",
    "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
  })
end

s.pod_target_xcconfig = xcconfig

if respond_to?(:install_modules_dependencies, true)
  install_modules_dependencies(s)  # <- Called AFTER manual flags
end

Problem

In React Native 0.81, iOS dependencies ship as precompiled XCFrameworks and install_modules_dependencies handles all New Architecture setup automatically. Manually setting folly_compiler_flags before calling it causes conflicts because those Folly headers don't exist in the precompiled setup.

Fix

Let install_modules_dependencies handle everything when available:

if respond_to?(:install_modules_dependencies, true)
  install_modules_dependencies(s)
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
    xcconfig.merge!({
      "DEFINES_MODULE" => "YES"
    })
  end
else
  # Fallback for older RN versions
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
    s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
    xcconfig.merge!({
      "DEFINES_MODULE" => "YES",
      "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
    })
  end
end

s.pod_target_xcconfig = xcconfig

Environment

  • Package: @datadog/mobile-react-native-session-replay@2.12.1
  • React Native: 0.81.4
  • Expo SDK: 54
  • Platform: iOS (EAS Build)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions