swiftxcodeswiftuixctestsimulator

Stop Xcode UITests running for light/dark and orientation permutations


I'm trying to run UITests just once. However, Xcode by default seems to run every permutation of light/dark color theme and device orientation and localizations. This means all UITests run 8 times (with 2 languages). With tests that can take a couple minutes, the time adds up.

Nothing in my UITest depends on the color theme, so I'd like to turn those permutations off always. The orientation and localization variations I might want sometimes but would generally also like to turn off.

Can I disable any/all of these permutations?

Minimal reproducible example:

  1. Make a new SwiftUI app project in Xcode 15.
  2. Add a UI Testing Bundle target
  3. Add a localization in the general app settings, then add a string catalog and at least one translation into the second language.
  4. Run a UITest
  5. Observe that it runs 8 times

Solution

  • You need to set this to false in your test class or remove the override altogether.

    override class var runsForEachTargetApplicationUIConfiguration: Bool {
        false
    }