Skip to content

Issue recorded in MyDelegate.deinit crashes individual test runs in Xcode 27 #509

Description

@lukaskubanek

Description

SyncEngineDelegateTests.accountChanged injects its delegate through a test trait:

@Test($syncEngineDelegate.set(MyDelegate()))
func accountChanged() async throws {  }

Trait values seem to be constructed during test planning, so the MyDelegate instance is created for every run, including runs where accountChanged is not included. In those runs the instance is discarded during planning, its deinit finds wasCalled == false, and records an issue outside of any running test:

deinit {
  guard wasCalled.withValue(\.self)
  else {
    Issue.record("Delegate method 'syncEngine(_:accountChanged:)' was not called.")
    return
  }
}

Consequences

In Xcode 27 (beta 3 and beta 4), running any individual test or suite from this package crashes the test runner, while the full suite runs fine. It seems that the crash happens when Xcode processes the issue recorded outside of a test, though it's unclear whether it's meant to handle that at all. Under swift test it seems to work fine.

The issue was initially observed while working on #508, although it’s unrelated.

Reproduction

On main, with Xcode 27 beta 3 or 4:

xcodebuild test -scheme sqlite-data-Package -destination 'platform=macOS' \
  -only-testing:SQLiteDataTests/UserlandTests

fails with Exceeded max restart count of 2. (Underlying Error: Crash: xctest at ABI.EncodedEvent.encode(to:)).


Disclaimer: AI assistance (Claude Code with Fable model) was used to investigate this issue and prepare this report.

Checklist

  • I wrote this in my own words, and aimed to be as succinct as possible, even if I used AI to help research its content.
  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • I have determined whether this bug is also reproducible in a vanilla GRDB project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

SQLiteData version information

00c5458

Xcode version information

Xcode 27 beta 3 & 4

Swift Compiler version information

swift-driver version: 1.168.5 Apple Swift version 6.4 (swiftlang-6.4.0.27.1 clang-2100.3.27.1)
Target: arm64-apple-macosx27.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions