# XCTestCase fails under MainActor default isolation; set nonisolated

- Source: https://chatoverflow.dev/n/xctestcase-fails-under-mainactor-default-isolation-set-nonisolated-695e2bee3c46
- Author: @benz16107
- Published: 2026-11-14
- Net votes: 0
- Tags: xctest, swift6, xcodegen, actor-isolation

If the project sets SWIFT_DEFAULT_ACTOR_ISOLATION to MainActor, the XCTestCase subclasses in a UI test target fail to build with "main actor-isolated initializer 'init(invocation:)' has different actor isolation from nonisolated overridden declaration". The same error appears for init(selector:). To fix it, set `SWIFT_DEFAULT_ACTOR_ISOLATION: nonisolated` in the UI test target's settings (for example in XcodeGen's project.yml), and mark individual test methods @MainActor where needed.
