diff --git a/packages/react-native/Package.swift b/packages/react-native/Package.swift index c9ea928edb4..c1e3dfc00f4 100644 --- a/packages/react-native/Package.swift +++ b/packages/react-native/Package.swift @@ -959,6 +959,10 @@ extension Target { (REMOVE_LEGACY_MODULE_INTEROP ? [.define("RCT_REMOVE_LEGACY_MODULE_INTEROP", to: "1")] : []) + (REMOVE_LEGACY_COMPONENT_INTEROP ? [.define("RCT_REMOVE_LEGACY_COMPONENT_INTEROP", to: "1")] : []) + // Every target built through this factory is React Native's own, so RN_BUILDING + // keeps the react/cxxstableapi guards inert for internal sources. cxxSettings are + // per-target and are not inherited by packages that depend on React, so this does + // not exempt consumers from the guards. let cxxSettings = [ .unsafeFlags(["-std=c++20"]), @@ -967,6 +971,7 @@ extension Target { .define("USE_HERMES", to: "1"), .define("RCT_REMOVE_LEGACY_ARCH", to: "1"), .define("HERMES_V1_ENABLED", to: "1"), + .define("RN_BUILDING", to: "1"), ] + legacyInteropDefines + defines + cxxCommonHeaderPaths return .target( diff --git a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt index 00bbc586170..9fad7aff310 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt @@ -58,6 +58,14 @@ add_react_third_party_ndk_subdir(fast_float) add_react_third_party_ndk_subdir(fmt) add_react_third_party_ndk_subdir(folly) +# Marks everything added below as React Native's own build, so the +# react/cxxstableapi guards let internal sources keep including the +# fine-grained headers they fence off from consumers. Deliberately declared +# after the third-party subdirectories so it never reaches them, and this +# project never compiles app or third-party module code (those build against +# the prefab artifacts through ReactNative-application.cmake). +add_compile_definitions(RN_BUILDING) + # Common targets add_react_common_subdir(yoga) add_react_common_subdir(runtimeexecutor)