Set SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG in the Debug config#244
Draft
radoslawrolka wants to merge 1 commit into
Draft
Set SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG in the Debug config#244radoslawrolka wants to merge 1 commit into
radoslawrolka wants to merge 1 commit into
Conversation
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.
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:
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 DEBUGis 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 installtime 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 DEBUGis 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)