Skip to content

Add guards for react/renderer/components/view (#57357) - #57357

Open
coado wants to merge 4 commits into
react:mainfrom
coado:export-D109847184
Open

Add guards for react/renderer/components/view (#57357)#57357
coado wants to merge 4 commits into
react:mainfrom
coado:export-D109847184

Conversation

@coado

@coado coado commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary:

Roll umbrella with umbrella guards for headers under react/renderer/components/view subtree. Initially, we assume that the entire target is public, so each header within includes a public umbrella guard.

Changelog:
[Internal]

Differential Revision: D109847184

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 29, 2026
@facebook-github-tools facebook-github-tools Bot added p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels Jun 29, 2026
@meta-codesync

meta-codesync Bot commented Jun 29, 2026

Copy link
Copy Markdown

@coado has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109847184.

coado added a commit to coado/react-native that referenced this pull request Jun 29, 2026
Summary:
Pull Request resolved: react#57357

Roll umbrella with umbrella guards for headers under `react/renderer/components/view` subtree. Initially, we assume that the entire target is public, so each header within includes a public umbrella guard.

Changelog:
[Internal]

Differential Revision: D109847184
@coado
coado force-pushed the export-D109847184 branch from fe00d62 to 4f9826c Compare June 29, 2026 10:54
@meta-codesync meta-codesync Bot changed the title Add guards for react/renderer/components/view Add guards for react/renderer/components/view (#57357) Jun 29, 2026
@coado
coado force-pushed the export-D109847184 branch from 4f9826c to fb72d26 Compare June 29, 2026 13:48
coado added a commit to coado/react-native that referenced this pull request Jun 29, 2026
Summary:
Pull Request resolved: react#57357

Roll umbrella with umbrella guards for headers under `react/renderer/components/view` subtree. Initially, we assume that the entire target is public, so each header within includes a public umbrella guard.

Changelog:
[Internal]

Differential Revision: D109847184
coado added a commit to coado/react-native that referenced this pull request Jun 29, 2026
Summary:
Pull Request resolved: react#57357

Roll umbrella with umbrella guards for headers under `react/renderer/components/view` subtree. Initially, we assume that the entire target is public, so each header within includes a public umbrella guard.

Changelog:
[Internal]

Differential Revision: D109847184
@coado
coado force-pushed the export-D109847184 branch from fb72d26 to 95f69ef Compare June 29, 2026 13:57
coado added a commit to coado/react-native that referenced this pull request Aug 7, 2026
Summary:
Pull Request resolved: react#57357

Roll umbrella with umbrella guards for headers under `react/renderer/components/view` subtree. Initially, we assume that the entire target is public, so each header within includes a public umbrella guard.

Changelog:
[Internal]

Differential Revision: D109847184
@coado
coado force-pushed the export-D109847184 branch from 95f69ef to 7db213d Compare August 7, 2026 15:42
coado and others added 4 commits August 10, 2026 02:24
Summary:
`install_modules_dependencies` is the helper every third-party New Architecture library calls from its own podspec, and `update_search_paths` covers the user project and the pod targets that don't go through it. Neither knew about `React-cxxstableapi`.

React Native's public C++ headers are starting to include the shared guard header `<react/cxxstableapi/UmbrellaGuard.h>`. The include is unconditional, so a third-party pod that includes any guarded React Native header has to be able to resolve it. Today it can't: in the default static-library mode `$(PODS_ROOT)/Headers/Public/React-cxxstableapi` is missing from the search path, and under `use_frameworks!` the `React_cxxstableapi.framework/Headers` entry is missing.

Declare the dependency and add the matching framework header search path in both places.

Changelog:
[iOS][Added] - Add a `React-cxxstableapi` dependency to third-party New Architecture pods so they can resolve React Native's C++ API guard headers

Differential Revision: D110052811
Summary:
React Native's public C++ headers are gaining guards from `react/cxxstableapi`. Those
guards turn a direct include of a fine-grained header into an error for consumers that
opt into the strict API by defining `RN_STRICT_API`. React Native's own sources keep
including those fine-grained headers directly, so they have to be exempt — the guards
recognise the exemption via `RN_BUILDING`.

Mark every first-party pod as part of React Native's own build by defining
`RN_BUILDING` for it, through a new `mark_as_react_native_build` helper called last in
each spec block (it merges into `GCC_PREPROCESSOR_DEFINITIONS` as `pod_target_xcconfig`
stands at call time, so a later assignment would drop it).

Third-party pods deliberately do NOT get this: they compile their own code against the
public API and must remain subject to the guards. For the same reason the definition
goes into `pod_target_xcconfig`, which applies to the pod's own target, rather than
`user_target_xcconfig`, which would leak it to the app.

Not applied to `third-party-podspecs/`, `sdks/hermes-engine`, or the codegen podspec
templates — those are third-party or app-side generated pods, and exempting them would
be an enforcement hole rather than a no-op.

This change is inert on its own: nothing behaves differently unless a consumer defines
`RN_STRICT_API`.

Changelog: [Internal]

Differential Revision: D115051089
…rgets

Summary:
Companion to the CocoaPods change: does the same for the other three build systems, so
every build has exactly one place that states "these targets are React Native's own".

React Native's public C++ headers are gaining guards from `react/cxxstableapi`, which
turn a direct include of a fine-grained header into an error for consumers that opt into
the strict API by defining `RN_STRICT_API`. React Native's own sources keep including
those headers directly, so they are exempted via `RN_BUILDING`.

Unlike CocoaPods, these three build systems each have a single chokepoint:

- CMake: one `add_compile_definitions(RN_BUILDING)` in the ReactAndroid JNI project,
  a directory property inherited by every `add_react_common_subdir` below it. It is
  declared *after* the third-party NDK subdirectories so glog/boost/folly/fmt never see
  it, and this project never compiles app or third-party module code — those build
  against the prefab artifacts through `ReactNative-application.cmake`. For that reason
  the flag deliberately does NOT go into `target_compile_reactnative_options`, which app
  and third-party module builds do call.
- SwiftPM: one `.define` in the shared `Target.reactNativeTarget` factory that every
  React Native target is created through. `cxxSettings` are per-target and are not
  inherited by packages that depend on React.
- Buck: a `_set_rn_building_flag` helper called from the four macros React Native's own
  targets use. These macros are also used by ~300 product packages that *consume* React
  Native, and those must stay subject to the guards, so the flag is scoped by package
  prefix rather than applied unconditionally. It is `preprocessor_flags`, deliberately
  not `exported_preprocessor_flags`, so dependents are not exempted either.

This change is inert on its own: nothing behaves differently unless a consumer defines
`RN_STRICT_API`.

Changelog: [Internal]

Differential Revision: D115051088
Summary:
Pull Request resolved: react#57357

Roll umbrella with umbrella guards for headers under `react/renderer/components/view` subtree. Initially, we assume that the entire target is public, so each header within includes a public umbrella guard.

Changelog:
[Internal]

Differential Revision: D109847184
@coado
coado force-pushed the export-D109847184 branch from 7db213d to 9353807 Compare August 10, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant