Skip to content

Set SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG in the Debug config#244

Draft
radoslawrolka wants to merge 1 commit into
react-native-community:mainfrom
radoslawrolka:rolkrado/add-swift-debug
Draft

Set SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG in the Debug config#244
radoslawrolka wants to merge 1 commit into
react-native-community:mainfrom
radoslawrolka:rolkrado/add-swift-debug

Conversation

@radoslawrolka

Copy link
Copy Markdown

Summary:

The app template's AppDelegate.swift gates the Metro bundle URL behind #if DEBUG (falling back to a non-existent main.jsbundle otherwise). In Swift, #if DEBUG is controlled by SWIFT_ACTIVE_COMPILATION_CONDITIONS, not by GCC_PREPROCESSOR_DEFINITIONS (which only affects C/ObjC/C++).

Today this flag is not committed in project.pbxproj; it is injected at pod install time by react_native_post_install (react_native_pods.rb), which calls set_build_setting for SWIFT_ACTIVE_COMPILATION_CONDITIONS = ["$(inherited)", "DEBUG"] on the user project's Debug config.

That means any setup that does not run CocoaPods (e.g. Swift Package Manager react-native experimental setup) never gets the flag, so #if DEBUG is false even in Debug builds. bundleURL() then returns nil and the app fails to launch with "No script url provided ... unsanitizedScriptURLString = (null)", even though Metro is running.

Baking the setting into the template makes Debug builds work regardless of the dependency manager and matches the value CocoaPods already sets, so CocoaPods-based apps are unaffected.

Changelog:

[IOS] [FIXED] - added missing SWIFT_ACTIVE_COMPILATION_CONDITIONS in debug config

Test Plan:

building app without coocapods (react/react-native #57332)

The app template's AppDelegate.swift gates the Metro bundle URL behind
`#if DEBUG` (falling back to a non-existent main.jsbundle otherwise). In
Swift, `#if DEBUG` is controlled by SWIFT_ACTIVE_COMPILATION_CONDITIONS,
not by GCC_PREPROCESSOR_DEFINITIONS (which only affects C/ObjC/C++).

Today this flag is not committed in project.pbxproj; it is injected at
`pod install` time by react_native_post_install (react_native_pods.rb),
which calls set_build_setting for SWIFT_ACTIVE_COMPILATION_CONDITIONS =
["$(inherited)", "DEBUG"] on the user project's Debug config.

That means any setup that does not run CocoaPods (e.g. Swift Package
Manager react-native experimental setup) never gets the flag, so `#if DEBUG` is false even in Debug
builds. bundleURL() then returns nil and the app fails to launch with
"No script url provided ... unsanitizedScriptURLString = (null)", even
though Metro is running.

Baking the setting into the template makes Debug builds work regardless
of the dependency manager and matches the value CocoaPods already sets,
so CocoaPods-based apps are unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant