Repository navigation
Conversation
Summary: Let iOS apps that use the Swift Package Manager setup enforce React Native's C++ stable API, matching the CocoaPods and Android opt-ins. Setting `RCT_STRICT_CXX_API=1` when running `npx react-native spm add` or `update` defines `RN_STRICT_API` in: - the app target (`GCC_PREPROCESSOR_DEFINITIONS`, seeded with `$(inherited)`), - every package the autolinker generates (inline `spm.modules` targets and the synthesized per-dependency packages), - the app codegen package (`ReactCodegen`, `ReactAppDependencyProvider`). React Native itself ships prebuilt in this setup, so none of its code is compiled with the flag. The Xcode build phase runs `spm sync` without the shell environment, so `add`/`update` record the choice in `.spm-injected.json` and every later sync regenerates the packages from that record. As with `pod install`, each `add`/`update` re-reads the variable: running `update` without it turns enforcement off, and `deinit` removes the app-target define along with the rest of the injection. Libraries that ship their own `Package.swift`, upstream or created with `spm scaffold`, are referenced as-is and keep their own settings. Changelog: [iOS][Added] - Add `RCT_STRICT_CXX_API` opt-in for the Swift Package Manager setup to enforce React Native's C++ stable API in app and library native code Differential Revision: D124985657
|
@coado has exported this pull request. If you are a Meta employee, you can view the originating Diff in D124985657. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Let iOS apps that use the Swift Package Manager setup enforce React Native's C++ stable API, matching the CocoaPods and Android opt-ins. Setting
RCT_STRICT_CXX_API=1when runningnpx react-native spm addorupdatedefinesRN_STRICT_APIin:GCC_PREPROCESSOR_DEFINITIONS, seeded with$(inherited)),spm.modulestargets and the synthesized per-dependency packages),ReactCodegen,ReactAppDependencyProvider).React Native itself ships prebuilt in this setup, so none of its code is compiled with the flag.
The Xcode build phase runs
spm syncwithout the shell environment, soadd/updaterecord the choice in.spm-injected.jsonand every later sync regenerates the packages from that record. As withpod install, eachadd/updatere-reads the variable: runningupdatewithout it turns enforcement off, anddeinitremoves the app-target define along with the rest of the injection.Libraries that ship their own
Package.swift, upstream or created withspm scaffold, are referenced as-is and keep their own settings.Changelog:
[iOS][Added] - Add
RCT_STRICT_CXX_APIopt-in for the Swift Package Manager setup to enforce React Native's C++ stable API in app and library native codeDifferential Revision: D124985657