Skip to content

Commit 69e19a9

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Cover cxxreact:jsbigstring with Stable API guards
Summary: Classifies `cxxreact:jsbigstring` as a public target under the C++ stable API three-tier visibility model. Adds `#include <react/cxxstableapi/UmbrellaGuard.h>` to the target's 2 exported C++ headers and introduces the module umbrella `React/JSBigString.h`, wiring the guard dependency into BUCK, CMake and CocoaPods and the umbrella into BUCK, CMake, CocoaPods, the iOS prebuild header config and the Android prefab export. Consumers that opt into `RN_STRICT_API` now get an error if they include the target's headers directly, and should include `<React/JSBigString.h>` instead; without that flag the guards are inert, so no existing build changes behaviour. Under `USE_FRAMEWORKS` the pod now maps its headers relative to `ReactCommon`, so they install under `cxxreact/` inside the built framework rather than at its root. Pods that pick up the framework's `Headers` directory through `install_modules_dependencies` are unaffected. `React-RCTFabric`, `ReactCommon` and `React-NativeModulesApple` pin their own search paths instead and are updated here; pods outside the repository that do the same have to make the equivalent change. Changelog: [iOS][Breaking] - Install `React-cxxreact` headers under `cxxreact/` inside its framework when `USE_FRAMEWORKS` is enabled. Pods that include `<cxxreact/...>` without calling `install_modules_dependencies` must add `React_cxxreact.framework/Headers` to `HEADER_SEARCH_PATHS`. Differential Revision: D119144023
1 parent bd53006 commit 69e19a9

11 files changed

Lines changed: 70 additions & 2 deletions

File tree

packages/react-native/React/React-RCTFabric.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Pod::Spec.new do |s|
6666
s.dependency "RCTSwiftUIWrapper"
6767

6868
add_dependency(s, "React-FabricImage")
69+
add_dependency(s, "React-cxxreact")
6970
add_dependency(s, "React-Fabric", :additional_framework_paths => [
7071
"react/renderer/components/scrollview/platform/cxx",
7172
"react/renderer/components/scrollview/platform/ios",

packages/react-native/ReactAndroid/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ val preparePrefab by
113113
// reactnativejni
114114
Pair("src/main/jni/react/jni", "react/jni/"),
115115
Pair("../ReactCommon/cxxreact/", "cxxreact/"),
116+
Pair("../ReactCommon/cxxreact/React/", "React/"),
116117
// react_featureflags
117118
Pair("../ReactCommon/react/featureflags/", "react/featureflags/"),
118119
Pair("../ReactCommon/react/featureflags/React/", "React/"),

packages/react-native/ReactCommon/ReactCommon.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Pod::Spec.new do |s|
5151

5252
ss.subspec "core" do |sss|
5353
sss.source_files = podspec_sources("react/nativemodule/core/ReactCommon/**/*.{cpp,h}", "react/nativemodule/core/ReactCommon/**/*.h")
54-
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_featureflags.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers\"" }
54+
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_featureflags.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-cxxreact/React_cxxreact.framework/Headers\"" }
5555
sss.dependency "React-bridging"
5656
sss.dependency "React-cxxreact", version
5757
sss.dependency "React-debug", version

packages/react-native/ReactCommon/cxxreact/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ file(GLOB react_cxxreact_SRC CONFIGURE_DEPENDS *.cpp)
1212
add_library(react_cxxreact OBJECT ${react_cxxreact_SRC})
1313

1414
target_include_directories(react_cxxreact PUBLIC ${REACT_COMMON_DIR})
15+
target_include_directories(react_cxxreact INTERFACE ${REACT_COMMON_DIR}/cxxreact)
1516

1617
target_link_libraries(react_cxxreact
1718
boost
@@ -22,6 +23,7 @@ target_link_libraries(react_cxxreact
2223
jsi
2324
jsinspector
2425
logger
26+
react_cxxstableapi
2527
reactperflogger
2628
runtimeexecutor
2729
react_debug)

packages/react-native/ReactCommon/cxxreact/JSBigString.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <memory>
1113
#include <string>
1214

packages/react-native/ReactCommon/cxxreact/JSBundleType.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <folly/Portability.h>
1113
#include <cstdint>
1214
#include <cstring>

packages/react-native/ReactCommon/cxxreact/React-cxxreact.podspec

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Pod::Spec.new do |s|
3434
}
3535
s.header_dir = "cxxreact"
3636

37+
resolve_use_frameworks(s, header_mappings_dir: "..", module_name: "React_cxxreact")
38+
3739
add_dependency(s, "React-jsinspector", :framework_name => 'jsinspector_modern')
3840
add_dependency(s, "React-jsinspectorcdp", :framework_name => 'jsinspector_moderncdp')
3941
add_dependency(s, "React-jsinspectortracing", :framework_name => 'jsinspector_moderntracing')
@@ -45,6 +47,7 @@ Pod::Spec.new do |s|
4547
s.dependency "React-logger", version
4648
s.dependency "React-debug", version
4749
s.dependency "React-timing", version
50+
s.dependency "React-cxxstableapi"
4851
add_dependency(s, "React-utils", :additional_framework_paths => ["react/utils/platform/ios"])
4952

5053
s.resource_bundles = {'React-cxxreact_privacy' => 'PrivacyInfo.xcprivacy'}
@@ -56,5 +59,11 @@ Pod::Spec.new do |s|
5659
add_rn_third_party_dependencies(s)
5760
add_rncore_dependency(s)
5861

62+
s.subspec "cxxreactUmbrella" do |ss|
63+
ss.source_files = "React/*.h"
64+
ss.header_dir = ""
65+
ss.header_mappings_dir = "."
66+
end
67+
5968
mark_as_react_native_build(s)
6069
end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
// =============================================================================
11+
// Umbrella header for the `cxxreact` module - public entry point.
12+
//
13+
// #include <React/JSBigString.h>
14+
//
15+
// Re-exports the module's public interface headers. React Native's own code
16+
// should keep using the fine-grained `<cxxreact/...>` includes; only outside
17+
// consumers use this umbrella.
18+
// =============================================================================
19+
20+
// Marks that the following headers are pulled in through the umbrella, so their
21+
// shared guard (<react/cxxstableapi/UmbrellaGuard.h>) accepts them. The marker
22+
// is saved and restored rather than defined and undefined: the scope ends at
23+
// this block, so later *direct* includes in the same TU are still caught, and
24+
// it nests inside an enclosing umbrella rather than disarming it.
25+
#pragma push_macro("RN_UMBRELLA_CONTEXT")
26+
#undef RN_UMBRELLA_CONTEXT
27+
#define RN_UMBRELLA_CONTEXT 1
28+
29+
#include <cxxreact/JSBigString.h>
30+
#include <cxxreact/JSBundleType.h>
31+
32+
#undef RN_UMBRELLA_CONTEXT
33+
#pragma pop_macro("RN_UMBRELLA_CONTEXT")

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/React-NativeModulesApple.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Pod::Spec.new do |s|
4040
s.dependency "React-bridging"
4141
s.dependency "React-callinvoker"
4242
s.dependency "React-Core"
43-
s.dependency "React-cxxreact"
43+
add_dependency(s, "React-cxxreact")
4444
s.dependency "React-jsi"
4545
s.dependency "React-featureflags"
4646
add_dependency(s, "React-debug")

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def self.install_modules_dependencies(spec, new_arch_enabled, folly_version = He
100100
.concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-rendererdebug", "React_rendererdebug", []))
101101
.concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-renderercss", "React_renderercss", []))
102102
.concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-cxxstableapi", "React_cxxstableapi", []))
103+
.concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-cxxreact", "React_cxxreact", []))
103104
.each { |search_path|
104105
header_search_paths << "\"#{search_path}\""
105106
}

0 commit comments

Comments
 (0)