apple / swift-testing

A modern, expressive testing package for Swift
Apache License 2.0
1.47k stars 52 forks source link

error: stored property 'xcTestCompatibleSelector' of 'Sendable'-conforming struct 'Test' has non-sendable type '__XCTestCompatibleSelector?' (aka 'Optional<Selector>') #491

Closed toffaletti closed 1 week ago

toffaletti commented 2 weeks ago

Description

Using swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain on macOS, I'm unable to use swift testing because of this error.

Expected behavior

I expect swift test --disable-xctest would build and run my tests.

Actual behavior

.build/checkouts/swift-testing/Sources/Testing/Test.swift:69:14: error: stored property 'xcTestCompatibleSelector' of 'Sendable'-conforming struct 'Test' has non-sendable type '__XCTestCompatibleSelector?' (aka 'Optional<Selector>')
 67 |   /// property is always `nil`.
 68 |   @_spi(ForToolsIntegrationOnly)
 69 |   public var xcTestCompatibleSelector: __XCTestCompatibleSelector?
    |              `- error: stored property 'xcTestCompatibleSelector' of 'Sendable'-conforming struct 'Test' has non-sendable type '__XCTestCompatibleSelector?' (aka 'Optional<Selector>')
 70 |
 71 |   /// An enumeration describing the evaluation state of a test's cases.

ObjectiveC.Selector:1:23: note: struct 'Selector' does not conform to the 'Sendable' protocol
1 | @frozen public struct Selector : ExpressibleByStringLiteral {
  |                       `- note: struct 'Selector' does not conform to the 'Sendable' protocol
2 |     public init(_ str: String)
3 |     public init(stringLiteral value: String)

Steps to reproduce

  1. Install swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain from swift.org
  2. Run swift test --disable-xctest

swift-testing version/commit hash

da1d5acb333dc480081aebf0670ea43d0a733c85

Swift & OS version (output of swift --version ; uname -a)

Apple Swift version 6.0-dev (LLVM 6e13b8be259f20f, Swift e7c2412597ed910)
Target: arm64-apple-macosx14.0
Darwin m14 23.6.0 Darwin Kernel Version 23.6.0: Thu Jun  6 16:11:38 PDT 2024; root:xnu-10063.140.26.0.1~13/DEVELOPMENT_ARM64_T6000 arm64
stmontgomery commented 2 weeks ago

I coincidentally just encountered this build failure also, but only when attempting to build using a newer Swift 6 development snapshot toolchain paired with an older Xcode 15.x. The newer Xcode 16 Beta contains SDKs whose ObjectiveC module has the Selector type marked Sendable, but earlier versions did not, so building using Xcode 16 Beta succeeds.

The other relevant factor which changed recently is that swift-testing's Package.swift changed to swift-tools-version: 6.0 in #467, and that in turn caused all of the package's targets to begin using the Swift 6 language mode.

I do not yet understand why this failure is not being hit by our CI system though, since it's using Xcode 15.1.

toffaletti commented 1 week ago

That makes sense, I also have an older Xcode:

Xcode 15.4
Build version 15F31d
stmontgomery commented 1 week ago

At this point, unless we identify some hard blocker which forces us to continue supporting versions of Xcode earlier than 16 Beta, we are inclined to close this and not make any workaround code changes. To anyone who encounters this problem, please ensure you are building using Xcode 16 Beta or later. This requirement has already been documented as part of the changes in #466