Skip to content

Force RCT_REMOVE_LEGACY_ARCH=1 for the entire OSS iOS framework - WIP !!#56821

Open
christophpurrer wants to merge 1 commit into
facebook:mainfrom
christophpurrer:export-D105118393
Open

Force RCT_REMOVE_LEGACY_ARCH=1 for the entire OSS iOS framework - WIP !!#56821
christophpurrer wants to merge 1 commit into
facebook:mainfrom
christophpurrer:export-D105118393

Conversation

@christophpurrer
Copy link
Copy Markdown
Contributor

@christophpurrer christophpurrer commented May 14, 2026

Summary:
The legacy (Paper) architecture has been removed from the React Native iOS sources. The remaining call sites are all behind #ifndef RCT_REMOVE_LEGACY_ARCH guards, so leaving the macro unset (or set to 0) now produces an unbuildable framework. Today the CocoaPods plumbing in react_native_pods.rb still treats RCT_REMOVE_LEGACY_ARCH as an opt-out env var ('0' ? '0' : '1'), and Package.swift already hard-codes the macro to 1 for the SwiftPM flow. This diff brings the CocoaPods flow in line with SwiftPM and makes the OSS framework always build with the legacy arch compiled out.

Changes in packages/react-native/scripts/react_native_pods.rb:

  • prepare_react_native_project! hard-sets ENV['RCT_REMOVE_LEGACY_ARCH'] = '1' at the top, before any other helper consults the variable.
  • use_react_native! re-asserts ENV['RCT_REMOVE_LEGACY_ARCH'] = '1' (the previous ... == '0' ? '0' : '1' opt-out is gone) so consumers that skip prepare_react_native_project! still get the flag.
  • react_native_post_install unconditionally adds -DRCT_REMOVE_LEGACY_ARCH=1 to every project's OTHER_CFLAGS / OTHER_CPLUSPLUSFLAGS (the old if/else that could remove the flag is gone).
  • New helper set_remove_legacy_arch_compiler_flag!(spec) appends -DRCT_REMOVE_LEGACY_ARCH=1 to a podspec's compiler_flags, preserving anything already there (e.g. js_engine_flags() in React-Core.podspec).

The new helper is invoked once per Meta-owned React-* podspec under packages/react-native/ (72 podspecs in total: every podspec that is not a third-party shim, not a codegen test fixture, not hermes-engine, and not Yoga). Baking the macro into each podspec's compiler_flags mirrors the .define("RCT_REMOVE_LEGACY_ARCH", to: "1") already present in Package.swift and provides a defensive belt-and-suspenders even for consumers that skip react_native_post_install.

Finally, the per-app ENV['RCT_REMOVE_LEGACY_ARCH'] = '1' override that previously sat at the top of packages/rn-tester/Podfile is now redundant and is removed; RNTester picks the flag up from the framework defaults like every other OSS app.

OSS impact: any app consuming react_native_pods.rb will always build React Native with -DRCT_REMOVE_LEGACY_ARCH=1. This matches the iOS source state. The env-var opt-out is gone -- setting RCT_REMOVE_LEGACY_ARCH=0 in the shell or CI no longer has any effect on OSS CocoaPods or SwiftPM builds.

Changelog:
[iOS][Changed] - Force RCT_REMOVE_LEGACY_ARCH=1 for the entire React Native iOS framework in OSS builds; the legacy (Paper) architecture is no longer a supported configuration. The RCT_REMOVE_LEGACY_ARCH=0 env-var opt-out has been removed from react_native_pods.rb.

Differential Revision: D105118393

@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 May 14, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 14, 2026

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

Summary:
The legacy (Paper) architecture has been removed from the React Native iOS sources. The remaining call sites are all behind `#ifndef RCT_REMOVE_LEGACY_ARCH` guards, so leaving the macro unset (or set to `0`) now produces an unbuildable framework. Today the CocoaPods plumbing in `react_native_pods.rb` still treats `RCT_REMOVE_LEGACY_ARCH` as an opt-out env var (`'0' ? '0' : '1'`), and `Package.swift` already hard-codes the macro to `1` for the SwiftPM flow. This diff brings the CocoaPods flow in line with SwiftPM and makes the OSS framework always build with the legacy arch compiled out.

Changes in `packages/react-native/scripts/react_native_pods.rb`:

- `prepare_react_native_project!` hard-sets `ENV['RCT_REMOVE_LEGACY_ARCH'] = '1'` at the top, before any other helper consults the variable.
- `use_react_native!` re-asserts `ENV['RCT_REMOVE_LEGACY_ARCH'] = '1'` (the previous `... == '0' ? '0' : '1'` opt-out is gone) so consumers that skip `prepare_react_native_project!` still get the flag.
- `react_native_post_install` unconditionally adds `-DRCT_REMOVE_LEGACY_ARCH=1` to every project's `OTHER_CFLAGS` / `OTHER_CPLUSPLUSFLAGS` (the old `if/else` that could remove the flag is gone).
- New helper `set_remove_legacy_arch_compiler_flag!(spec)` appends `-DRCT_REMOVE_LEGACY_ARCH=1` to a podspec's `compiler_flags`, preserving anything already there (e.g. `js_engine_flags()` in `React-Core.podspec`).

The new helper is invoked once per Meta-owned React-* podspec under `packages/react-native/` (72 podspecs in total: every podspec that is not a third-party shim, not a codegen test fixture, not `hermes-engine`, and not `Yoga`). Baking the macro into each podspec's `compiler_flags` mirrors the `.define("RCT_REMOVE_LEGACY_ARCH", to: "1")` already present in `Package.swift` and provides a defensive belt-and-suspenders even for consumers that skip `react_native_post_install`.

Finally, the per-app `ENV['RCT_REMOVE_LEGACY_ARCH'] = '1'` override that previously sat at the top of `packages/rn-tester/Podfile` is now redundant and is removed; RNTester picks the flag up from the framework defaults like every other OSS app.

OSS impact: any app consuming `react_native_pods.rb` will always build React Native with `-DRCT_REMOVE_LEGACY_ARCH=1`. This matches the iOS source state. The env-var opt-out is gone -- setting `RCT_REMOVE_LEGACY_ARCH=0` in the shell or CI no longer has any effect on OSS CocoaPods or SwiftPM builds.

Changelog:
[iOS][Changed] - Force `RCT_REMOVE_LEGACY_ARCH=1` for the entire React Native iOS framework in OSS builds; the legacy (Paper) architecture is no longer a supported configuration. The `RCT_REMOVE_LEGACY_ARCH=0` env-var opt-out has been removed from `react_native_pods.rb`.

Differential Revision: D105118393
@meta-codesync meta-codesync Bot changed the title Always set RCT_REMOVE_LEGACY_ARCH for the open-source RNTester iOS build Force RCT_REMOVE_LEGACY_ARCH=1 for the entire OSS iOS framework - WIP !! May 14, 2026
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. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant