You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bd84060
Browse filesBrowse the repository at this point in the historyBrowse files
Add CocoaPods opt-ins for RN_STRICT_API and RN_ALLOW_FRAMEWORKS (#59037)
Summary:
Pull Request resolved: #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
0 commit comments