XCode 26 - xcodebuild command hangs on XCFail

On XCode 26.x, calling XCFail with continueAfterFailure set to false causes xcodebuild command to hang indefinitely if the XCUIApplication object is stored outside the test method.

  1. Create a new template iOS App project with UI tests
  2. Add XCFail(...) to a UI test test-case
  3. Set the XCUIApplication in self.app (avoiding this fixes the hang)
  4. Run tests with xcodebuild test
  5. The terminal hangs forever

Reproduction example

import XCTest

final class TestAppUITests: XCTestCase {
    var app: XCUIApplication? = nil

    override func setUpWithError() throws {
        continueAfterFailure = false
    }

    override func tearDownWithError() throws {
        app?.terminate()
    }

    @MainActor
    func testExample() throws {
        let app = XCUIApplication()
        self.app = app // <- HERE this causes the problem
        app.launch()

        XCTFail()
    }
}

Reproduction environment

  • macOS Sequoia 15.7.3
  • Tested XCode 26.3 and XCode 26.2 have the hang
  • Tested XCode 16.4 does work as expected

XCode 16.4

The issue does not happen on XCode 16.4, and is likely introduced in XCode 26.

Related threads:

Work-around

Do not store XCUIApplication in the XCTestCase instance, maintain it scoped to the test methods.

I am reviewing this report to verify information is accurate.

I can't seem to reproduce this reliably on a test project and not at all on an isolated environment, so you can take the information above with a grain of salt.

XCode 26 - xcodebuild command hangs on XCFail
 
 
Q