Target Branch
0.87
Link to commit or PR to be picked
react/react-native#57914
Landed on main as react/react-native@4433cdb
Description
Swift's #if DEBUG is gated by SWIFT_ACTIVE_COMPILATION_CONDITIONS, not by GCC_PREPROCESSOR_DEFINITIONS (which only reaches C/ObjC/C++). The app template does not commit that setting; CocoaPods injects it at pod install time (react_native_post_install → set_build_setting SWIFT_ACTIVE_COMPILATION_CONDITIONS = ["$(inherited)", "DEBUG"] on Debug).
An app set up with the experimental SwiftPM support never runs CocoaPods, so #if DEBUG is false even in a Debug build: AppDelegate.swift's bundleURL() skips the Metro URL and falls back to a main.jsbundle that a Debug build never produced. The app dies at launch with No script url provided ... unsanitizedScriptURLString = (null) while Metro is running.
This makes SwiftPM Debug builds unusable on 0.87 out of the box, which is why it is worth picking.
The fix injects the setting from spm add/update alongside the other React build settings, into debug-flavored configurations only (the same flavorForBuildConfiguration test that selects the debug xcframeworks). Doing it in the injector rather than in the app template fixes existing apps too, and keeps the setting on the one code path that knows a project is SwiftPM-integrated.
The merge is additive and reversible like every other injected setting: a config that already defines DEBUG is left byte-identical. Related context: react-native-community/template#244.
Target Branch
0.87
Link to commit or PR to be picked
react/react-native#57914
Landed on
mainas react/react-native@4433cdbDescription
Swift's
#if DEBUGis gated bySWIFT_ACTIVE_COMPILATION_CONDITIONS, not byGCC_PREPROCESSOR_DEFINITIONS(which only reaches C/ObjC/C++). The app template does not commit that setting; CocoaPods injects it atpod installtime (react_native_post_install→set_build_setting SWIFT_ACTIVE_COMPILATION_CONDITIONS = ["$(inherited)", "DEBUG"]on Debug).An app set up with the experimental SwiftPM support never runs CocoaPods, so
#if DEBUGis false even in a Debug build:AppDelegate.swift'sbundleURL()skips the Metro URL and falls back to amain.jsbundlethat a Debug build never produced. The app dies at launch withNo script url provided ... unsanitizedScriptURLString = (null)while Metro is running.This makes SwiftPM Debug builds unusable on 0.87 out of the box, which is why it is worth picking.
The fix injects the setting from
spm add/updatealongside the other React build settings, into debug-flavored configurations only (the sameflavorForBuildConfigurationtest that selects the debug xcframeworks). Doing it in the injector rather than in the app template fixes existing apps too, and keeps the setting on the one code path that knows a project is SwiftPM-integrated.The merge is additive and reversible like every other injected setting: a config that already defines
DEBUGis left byte-identical. Related context: react-native-community/template#244.