fix: Respect app's user interface style override #223
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.
Hey guys, I'm working on an app that doesn't support dark mode yet (I know, it's a shame 😅). I ran into some issues when activating the debugger, and this PR solves that problem.
Summary
Respect host app's user interface style override when determining dark mode state in UserInterfaceToolkit to prevent forced dark mode in apps that explicitly disable it.
Problem
When a UIKit app explicitly overrides
overrideUserInterfaceStyleto.light(e.g., in AppDelegate), DebugSwift still applies dark mode to its interface. This causes visual issues where all views appear black/incorrect because the library's dark mode theming conflicts with the host app's light-only configuration.Root Cause
UserInterfaceToolkit.swiftwas checkingUIScreen.main.traitCollection.userInterfaceStyleto determine dark mode stateoverrideUserInterfaceStyleto disable dark mode support were having their preference bypassedSolution
Check the actual window's trait collection first before falling back to the system preference. The window's trait collection respects app-level
overrideUserInterfaceStylesettings, ensuring DebugSwift adapts to the host app's configuration. This approach maintains compatibility with all integration scenarios:Changes
UserInterfaceToolkit.swift:100-109UIWindow.keyWindow?.traitCollection.userInterfaceStylefirst (respects app overrides)UIScreen.main.traitCollection.userInterfaceStyleif no window is available yet (system preference)