Skip to content

Add CocoaPods opt-ins for RN_STRICT_API and RN_ALLOW_FRAMEWORKS (#59037) - #59037

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

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

Conversation

@coado

@coado coado commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Let iOS apps that use CocoaPods enforce React Native's C++ stable API, and control its "for frameworks" warning, with two env vars read at pod install:

  • RN_STRICT_API=1 defines the RN_STRICT_API macro, which arms the react/cxxstableapi guards. A direct include of a public module header is an error pointing to the module's umbrella (<React/<Module>.h>), a private header is an error, and a "for frameworks" header is a warning.
  • RN_ALLOW_FRAMEWORKS=1 defines the RN_ALLOW_FRAMEWORKS macro, which silences that warning.

Each variable is named after the macro it defines, matching the Android opt-in, which passes RN_STRICT_API to CMake.

Both macros are added to the app project and the Pods project, so they reach the app, third-party pods and app codegen. React Native's own pods are unaffected because they define RN_BUILDING. Both are off by default; running pod install without a variable removes its define again. This mirrors the existing RCT_REMOVE_LEGACY_* opt-ins and the Android opt-in.

Who silences the "for frameworks" warning for which code:

  • A library that uses for-frameworks headers declares RN_ALLOW_FRAMEWORKS for its own pod (pod_target_xcconfig). That covers its own build only and never reaches the app or other pods.
  • The app author sets RN_ALLOW_FRAMEWORKS=1 before pod install for the app's own code. It also silences libraries that use those headers without declaring it, which is on the library.
  • The generated ReactCodegen and ReactAppDependencyProvider pods always define RN_ALLOW_FRAMEWORKS: nobody can act on a warning in generated code, and libraries are already held to the API in their own pods.

Changelog:
[iOS][Added] - Add RN_STRICT_API and RN_ALLOW_FRAMEWORKS CocoaPods opt-ins to enforce React Native's C++ stable API in app and library native code

Reviewed By: cipolleschi

Differential Revision: D124979668

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

meta-codesync Bot commented Oct 13, 2026

Copy link
Copy Markdown

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

@meta-codesync meta-codesync Bot changed the title Add CocoaPods opt-in for RN_STRICT_API Add CocoaPods opt-in for RN_STRICT_API (#59037) Oct 13, 2026
coado added a commit to coado/react-native that referenced this pull request Oct 13, 2026
Summary:

Let iOS apps that use CocoaPods enforce React Native's C++ stable API. Setting `RCT_STRICT_CXX_API=1` before `pod install` defines `RN_STRICT_API` in the app project and the Pods project, so the `react/cxxstableapi` guards apply to the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`.

Under the flag, a direct include of a public module header is an error that points to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning that `RN_ALLOW_FRAMEWORKS` silences.

The flag is off by default: libraries that still include React Native's internal headers would stop compiling. Turning it back off removes the define on the next `pod install`. This mirrors the existing `RCT_REMOVE_LEGACY_*` opt-ins and matches the scope of the Android opt-in.

Changelog:
[iOS][Added] - Add `RCT_STRICT_CXX_API` CocoaPods opt-in to enforce React Native's C++ stable API in app and library native code

Differential Revision: D124979668
@coado
coado force-pushed the export-D124979668 branch from e61a4cf to ba43662 Compare October 13, 2026 14:37
coado added a commit to coado/react-native that referenced this pull request Oct 13, 2026
Summary:

Let iOS apps that use CocoaPods enforce React Native's C++ stable API. Setting `RN_STRICT_API=1` before `pod install` defines `RN_STRICT_API` in the app project and the Pods project, so the `react/cxxstableapi` guards apply to the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`.

Under the flag, a direct include of a public module header is an error that points to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning that `RN_ALLOW_FRAMEWORKS` silences.

Changelog:
[iOS][Added] - Add `RCT_STRICT_CXX_API` CocoaPods opt-in to enforce React Native's C++ stable API in app and library native code

Differential Revision: D124979668
@coado
coado force-pushed the export-D124979668 branch from ba43662 to 685f223 Compare October 13, 2026 15:11
coado added a commit to coado/react-native that referenced this pull request Oct 13, 2026
Summary:

Let iOS apps that use CocoaPods enforce React Native's C++ stable API. Setting `RN_STRICT_API=1` before `pod install` defines `RN_STRICT_API` in the app project and the Pods project, so the `react/cxxstableapi` guards apply to the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`.

Under the flag, a direct include of a public module header is an error that points to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning that `RN_ALLOW_FRAMEWORKS` silences.

Changelog:
[iOS][Added] - Add `RCT_STRICT_CXX_API` CocoaPods opt-in to enforce React Native's C++ stable API in app and library native code

Differential Revision: D124979668
@coado
coado force-pushed the export-D124979668 branch from 685f223 to c191dde Compare October 13, 2026 15:13
coado added a commit to coado/react-native that referenced this pull request Oct 13, 2026
Summary:
Pull Request resolved: react#59037

Let iOS apps that use CocoaPods enforce React Native's C++ stable API. Setting `RN_STRICT_API=1` before `pod install` defines `RN_STRICT_API` in the app project and the Pods project, so the `react/cxxstableapi` guards apply to the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`.

Under the flag, a direct include of a public module header is an error that points to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning that `RN_ALLOW_FRAMEWORKS` silences.

Changelog:
[iOS][Added] - Add `RCT_STRICT_CXX_API` CocoaPods opt-in to enforce React Native's C++ stable API in app and library native code

Differential Revision: D124979668
@coado
coado force-pushed the export-D124979668 branch 2 times, most recently from 8202e06 to fe0e701 Compare October 14, 2026 08:11
coado added a commit to coado/react-native that referenced this pull request Oct 14, 2026
Summary:

Let iOS apps that use CocoaPods enforce React Native's C++ stable API. Setting `RN_STRICT_API=1` before `pod install` defines `RN_STRICT_API` in the app project and the Pods project, so the `react/cxxstableapi` guards apply to the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`.

Under the flag, a direct include of a public module header is an error that points to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning that `RN_ALLOW_FRAMEWORKS` silences.

Changelog:
[iOS][Added] - Add `RCT_STRICT_CXX_API` CocoaPods opt-in to enforce React Native's C++ stable API in app and library native code

Differential Revision: D124979668
coado added a commit to coado/react-native that referenced this pull request Oct 14, 2026
Summary:

Let iOS apps that use CocoaPods enforce React Native's C++ stable API. Setting `RN_STRICT_API=1` before `pod install` defines `RN_STRICT_API` in the app project and the Pods project, so the `react/cxxstableapi` guards apply to the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`.

Under the flag, a direct include of a public module header is an error that points to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning that `RN_ALLOW_FRAMEWORKS` silences.

Changelog:
[iOS][Added] - Add `RCT_STRICT_CXX_API` CocoaPods opt-in to enforce React Native's C++ stable API in app and library native code

Differential Revision: D124979668
@coado
coado force-pushed the export-D124979668 branch 2 times, most recently from 74cbb50 to e096ea5 Compare October 14, 2026 08:14
coado added a commit to coado/react-native that referenced this pull request Oct 14, 2026
Summary:
Pull Request resolved: react#59037

Let iOS apps that use CocoaPods enforce React Native's C++ stable API. Setting `RN_STRICT_API=1` before `pod install` defines `RN_STRICT_API` in the app project and the Pods project, so the `react/cxxstableapi` guards apply to the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`.

Under the flag, a direct include of a public module header is an error that points to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning that `RN_ALLOW_FRAMEWORKS` silences.

Changelog:
[iOS][Added] - Add `RCT_STRICT_CXX_API` CocoaPods opt-in to enforce React Native's C++ stable API in app and library native code

Differential Revision: D124979668
coado added a commit to coado/react-native that referenced this pull request Oct 14, 2026
Summary:
Pull Request resolved: react#59037

Let iOS apps that use CocoaPods enforce React Native's C++ stable API. Setting `RN_STRICT_API=1` before `pod install` defines `RN_STRICT_API` in the app project and the Pods project, so the `react/cxxstableapi` guards apply to the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`.

Under the flag, a direct include of a public module header is an error that points to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning that `RN_ALLOW_FRAMEWORKS` silences.

Changelog:
[iOS][Added] - Add `RCT_STRICT_CXX_API` CocoaPods opt-in to enforce React Native's C++ stable API in app and library native code

Differential Revision: D124979668
@coado
coado force-pushed the export-D124979668 branch from e096ea5 to 18b3865 Compare October 14, 2026 08:19
@meta-codesync meta-codesync Bot changed the title Add CocoaPods opt-in for RN_STRICT_API (#59037) Add CocoaPods opt-ins for RN_STRICT_API and RN_ALLOW_FRAMEWORKS (#59037) Oct 16, 2026
@coado
coado force-pushed the export-D124979668 branch from 18b3865 to 29cf648 Compare October 16, 2026 11:55
coado added a commit to coado/react-native that referenced this pull request Oct 16, 2026
…t#59037)

Summary:

Let iOS apps that use CocoaPods enforce React Native's C++ stable API, and control its "for frameworks" warning, with two env vars read at `pod install`:

- `RN_STRICT_API=1` defines the `RN_STRICT_API` macro, which arms the `react/cxxstableapi` guards. A direct include of a public module header is an error pointing to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning.
- `RN_ALLOW_FRAMEWORKS=1` defines the `RN_ALLOW_FRAMEWORKS` macro, which silences that warning.

Each variable is named after the macro it defines, matching the Android opt-in, which passes `RN_STRICT_API` to CMake.

Both macros are added to the app project and the Pods project, so they reach the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`. Both are off by default; running `pod install` without a variable removes its define again. This mirrors the existing `RCT_REMOVE_LEGACY_*` opt-ins and the Android opt-in.

Who silences the "for frameworks" warning for which code:
- A library that uses for-frameworks headers declares `RN_ALLOW_FRAMEWORKS` for its own pod (`pod_target_xcconfig`). That covers its own build only and never reaches the app or other pods.
- The app author sets `RN_ALLOW_FRAMEWORKS=1` before `pod install` for the app's own code. It also silences libraries that use those headers without declaring it, which is on the library.
- The generated `ReactCodegen` and `ReactAppDependencyProvider` pods always define `RN_ALLOW_FRAMEWORKS`: nobody can act on a warning in generated code, and libraries are already held to the API in their own pods.

Changelog:
[iOS][Added] - Add `RN_STRICT_API` and `RN_ALLOW_FRAMEWORKS` CocoaPods opt-ins to enforce React Native's C++ stable API in app and library native code

Reviewed By: cipolleschi

Differential Revision: D124979668
…t#59037)

Summary:
Pull Request resolved: react#59037

Let iOS apps that use CocoaPods enforce React Native's C++ stable API, and control its "for frameworks" warning, with two env vars read at `pod install`:

- `RN_STRICT_API=1` defines the `RN_STRICT_API` macro, which arms the `react/cxxstableapi` guards. A direct include of a public module header is an error pointing to the module's umbrella (`<React/<Module>.h>`), a private header is an error, and a "for frameworks" header is a warning.
- `RN_ALLOW_FRAMEWORKS=1` defines the `RN_ALLOW_FRAMEWORKS` macro, which silences that warning.

Each variable is named after the macro it defines, matching the Android opt-in, which passes `RN_STRICT_API` to CMake.

Both macros are added to the app project and the Pods project, so they reach the app, third-party pods and app codegen. React Native's own pods are unaffected because they define `RN_BUILDING`. Both are off by default; running `pod install` without a variable removes its define again. This mirrors the existing `RCT_REMOVE_LEGACY_*` opt-ins and the Android opt-in.

Who silences the "for frameworks" warning for which code:
- A library that uses for-frameworks headers declares `RN_ALLOW_FRAMEWORKS` for its own pod (`pod_target_xcconfig`). That covers its own build only and never reaches the app or other pods.
- The app author sets `RN_ALLOW_FRAMEWORKS=1` before `pod install` for the app's own code. It also silences libraries that use those headers without declaring it, which is on the library.
- The generated `ReactCodegen` and `ReactAppDependencyProvider` pods always define `RN_ALLOW_FRAMEWORKS`: nobody can act on a warning in generated code, and libraries are already held to the API in their own pods.

Changelog:
[iOS][Added] - Add `RN_STRICT_API` and `RN_ALLOW_FRAMEWORKS` CocoaPods opt-ins to enforce React Native's C++ stable API in app and library native code

Reviewed By: cipolleschi

Differential Revision: D124979668
@coado
coado force-pushed the export-D124979668 branch from 29cf648 to 94637b6 Compare October 16, 2026 11:58

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