Propagate RCT_REMOVE_LEGACY_ARCH to SWIFT_ACTIVE_COMPILATION_CONDITIONS#56974
Open
christophpurrer wants to merge 1 commit into
Open
Propagate RCT_REMOVE_LEGACY_ARCH to SWIFT_ACTIVE_COMPILATION_CONDITIONS#56974christophpurrer wants to merge 1 commit into
RCT_REMOVE_LEGACY_ARCH to SWIFT_ACTIVE_COMPILATION_CONDITIONS#56974christophpurrer wants to merge 1 commit into
Conversation
|
@christophpurrer has exported this pull request. If you are a Meta employee, you can view the originating Diff in D106466169. |
…TIONS` Summary: Mirrors the existing C/C++ `-DRCT_REMOVE_LEGACY_ARCH=1` flag into Swift's `SWIFT_ACTIVE_COMPILATION_CONDITIONS` so Swift sources (notably user `AppDelegate.swift` files derived from the community template) can branch on `#if !RCT_REMOVE_LEGACY_ARCH`. Until now, `react_native_pods.rb` only added `-DRCT_REMOVE_LEGACY_ARCH=1` via `add_compiler_flag_to_project`, which sets `OTHER_CFLAGS` / `OTHER_CPLUSPLUSFLAGS`. Swift does not consume those; it reads `SWIFT_ACTIVE_COMPILATION_CONDITIONS`. As a result, `#if RCT_REMOVE_LEGACY_ARCH` in Swift was silently always false, and templates that need to keep `sourceURLForBridge:` for legacy-arch builds while compiling cleanly against legacy-arch-removed builds had no way to express that. Adds two helpers in `ReactNativePodsUtils`: - `add_swift_active_compilation_condition_to_project(installer, condition)` - `remove_swift_active_compilation_condition_from_project(installer, condition)` Both are additive and idempotent: they normalise the existing `SWIFT_ACTIVE_COMPILATION_CONDITIONS` value (which may be nil, a string, or an array) into an array, preserve `$(inherited)` and any pre-existing conditions such as `DEBUG`, and dedupe on insert. Repeated `pod install` runs produce stable output. `react_native_pods.rb` now calls the add/remove helpers alongside the existing C-flag add/remove inside the `RCT_REMOVE_LEGACY_ARCH` env-var branch. Changelog: [iOS][Added] - Propagate `RCT_REMOVE_LEGACY_ARCH` into `SWIFT_ACTIVE_COMPILATION_CONDITIONS` so Swift code in apps and the community template can branch on `#if !RCT_REMOVE_LEGACY_ARCH`, matching the existing C/C++ `-DRCT_REMOVE_LEGACY_ARCH=1` flag. Differential Revision: D106466169
ac8ed2c to
7646383
Compare
christophpurrer
added a commit
to christophpurrer/react-native-community-template
that referenced
this pull request
May 27, 2026
…acy arch removal The sourceURLForBridge: method will be removed from RCTBridgeDelegate in facebook/react-native#56831 due to the RCT_REMOVE_LEGACY_ARCH clean up. Then the override no longer overrides anything and fails Swift compilation. bundleURL() — already present below — is the replacement API on RCTReactNativeFactoryDelegate. This change depends on facebook/react-native#56974
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:
Mirrors the existing C/C++
-DRCT_REMOVE_LEGACY_ARCH=1flag into Swift'sSWIFT_ACTIVE_COMPILATION_CONDITIONSso Swift sources (notably userAppDelegate.swiftfiles derived from the community template) can branch on#if !RCT_REMOVE_LEGACY_ARCH.Until now,
react_native_pods.rbonly added-DRCT_REMOVE_LEGACY_ARCH=1viaadd_compiler_flag_to_project, which setsOTHER_CFLAGS/OTHER_CPLUSPLUSFLAGS. Swift does not consume those; it readsSWIFT_ACTIVE_COMPILATION_CONDITIONS. As a result,#if RCT_REMOVE_LEGACY_ARCHin Swift was silently always false, and templates that need to keepsourceURLForBridge:for legacy-arch builds while compiling cleanly against legacy-arch-removed builds had no way to express that.Adds two helpers in
ReactNativePodsUtils:add_swift_active_compilation_condition_to_project(installer, condition)remove_swift_active_compilation_condition_from_project(installer, condition)Both are additive and idempotent: they normalise the existing
SWIFT_ACTIVE_COMPILATION_CONDITIONSvalue (which may be nil, a string, or an array) into an array, preserve$(inherited)and any pre-existing conditions such asDEBUG, and dedupe on insert. Repeatedpod installruns produce stable output.react_native_pods.rbnow calls the add/remove helpers alongside the existing C-flag add/remove inside theRCT_REMOVE_LEGACY_ARCHenv-var branch.Changelog:
[iOS][Added] - Propagate
RCT_REMOVE_LEGACY_ARCHintoSWIFT_ACTIVE_COMPILATION_CONDITIONSso Swift code in apps and the community template can branch on#if !RCT_REMOVE_LEGACY_ARCH, matching the existing C/C++-DRCT_REMOVE_LEGACY_ARCH=1flag.Differential Revision: D106466169