From 6fc856b4860c689c837bbdfa23601fcf2b3365f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 2 Nov 2026 08:33:18 +0100 Subject: [PATCH] fix(macos): connect the runner process to the window server before XCTest events Xcode 27.2 aborts in CGS_REQUIRE_INIT on the first synthesized event because the UI-test runner never touches NSApplication. Touch NSApplication.shared in the RunnerTests class setUp on macOS. Co-Authored-By: Claude Sonnet 5.5 --- .../AgentDeviceRunnerUITests/RunnerTests.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift index d152fa5cda..f02f005a39 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift @@ -245,6 +245,15 @@ final class RunnerTests: XCTestCase { // MARK: - XCTest Entry +#if os(macOS) + // Xcode 27.2 aborts in CGS_REQUIRE_INIT on the first synthesized event unless the process is + // connected to the window server; the UI-test runner has no NSApplication to do it (#4142). + override class func setUp() { + super.setUp() + MainActor.assumeIsolated { _ = NSApplication.shared } + } + +#endif override func setUp() { continueAfterFailure = true }