Skip to content

Keep RCTHermesInstanceFactory.h off the "for frameworks" C API header - #59111

Open
coado wants to merge 1 commit into
react:mainfrom
coado:export-D125448714
Open

coado wants to merge 1 commit into
react:mainfrom
coado:export-D125448714

Conversation

@coado

@coado coado commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Summary:
RCTHermesInstanceFactory.h is part of React's umbrella header, so every import React compiles it. It imported <react/runtime/JSRuntimeFactoryCAPI.h>, which the C++ stable API classifies as "for frameworks", only to get the opaque JSRuntimeFactoryRef handle. So an app that defines RN_STRICT_API gets a "for frameworks" warning from React Native's own header that it cannot act on: with the prebuilt SwiftPM artifacts the warning fires while the React module is built with the app's macros.

Declare the handle in the header instead, the same way RCTJSRuntimeConfiguratorProtocol.h already does (typedef void *JSRuntimeFactoryRef;). The type and ABI are unchanged, and identical typedefs may be repeated in C and C++, so a translation unit that also includes JSRuntimeFactoryCAPI.h still compiles. Code that needs the rest of the C API, such as js_runtime_factory_destroy, imports JSRuntimeFactoryCAPI.h directly, as RCTRootViewFactory.mm already does.

With this, no header in React's umbrella reaches a stable API guard when compiled as Objective-C.

Changelog:
[Internal]

Differential Revision: D125448714

Summary:
`RCTHermesInstanceFactory.h` is part of React's umbrella header, so every `import React` compiles it. It imported `<react/runtime/JSRuntimeFactoryCAPI.h>`, which the C++ stable API classifies as "for frameworks", only to get the opaque `JSRuntimeFactoryRef` handle. So an app that defines `RN_STRICT_API` gets a "for frameworks" warning from React Native's own header that it cannot act on: with the prebuilt SwiftPM artifacts the warning fires while the `React` module is built with the app's macros.

Declare the handle in the header instead, the same way `RCTJSRuntimeConfiguratorProtocol.h` already does (`typedef void *JSRuntimeFactoryRef;`). The type and ABI are unchanged, and identical typedefs may be repeated in C and C++, so a translation unit that also includes `JSRuntimeFactoryCAPI.h` still compiles. Code that needs the rest of the C API, such as `js_runtime_factory_destroy`, imports `JSRuntimeFactoryCAPI.h` directly, as `RCTRootViewFactory.mm` already does.

With this, no header in React's umbrella reaches a stable API guard when compiled as Objective-C.

Changelog:
[Internal]

Differential Revision: D125448714
@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 Oct 15, 2026
@facebook-github-tools facebook-github-tools Bot added p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels Oct 15, 2026
@meta-codesync

meta-codesync Bot commented Oct 15, 2026

Copy link
Copy Markdown

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

This branch has not been deployed

No deployments
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