I am seeing a regression with XCUIDevice.shared.appearance = .dark in UI tests that only affects xcodebuild, not Xcode’s UI test runner.
Setup
• UI tests written using XCTest
• Dark mode forced in setUp() using:
XCUIDevice.shared.appearance = .dark
• Tests target an iOS simulator
• Same test target, same scheme
Expected behavior
The app launches in Dark Mode for UI tests, as it did previously.
Actual behavior
• When running UI tests from Xcode (Product > Test), Dark Mode is applied correctly.
• When running the same UI tests via xcodebuild test, Dark Mode is ignored and the app launches in Light Mode.
• No test failures, no warnings, no logs indicating the appearance override was skipped.
Regression details
• This used to work on older iOS versions when running via xcodebuild.
• The regression appears after updating iOS simulators (exact version boundary still unclear).
• No relevant changes were made to the test code, scheme, or CI configuration.
• xcodebuild otherwise launches and runs UI tests normally.
Notes
• The issue is specific to XCUIDevice.shared.appearance.
• Other UI test functionality behaves as expected.
• This makes CI results inconsistent with local Xcode runs and breaks visual assumptions in snapshot and layout-based tests.
Question
Is this a known regression or an intentional behavior change in recent iOS / Xcode versions? If intentional, what is the supported way to reliably force Dark Mode in UI tests when running via xcodebuild?
This currently makes xcodebuild-based CI UI testing unreliable compared to Xcode’s test runner.