Skip to content

fix: swift testing compiler mode check#353

Open
Archdoog wants to merge 1 commit intohmlongco:mainfrom
Archdoog:xcode-16.3-availability
Open

fix: swift testing compiler mode check#353
Archdoog wants to merge 1 commit intohmlongco:mainfrom
Archdoog:xcode-16.3-availability

Conversation

@Archdoog
Copy link

@Archdoog Archdoog commented Mar 23, 2026

Issue

Swift testing is flagged as swift 6 and 6.1, but this seems to be the compiler version because you're able to use swift testing in a Swift 5 configured project/package.

The #if swift(>=6.1) in the original FactoryTesting trait meant you could use FactoryKit with a swift 5 project with swift testing. The swift tests would build fine with @Suite(.container) but the trait would never override the singleton under the @TaskLocal resulting in race conditions, missed registrations, etc.

Some research lead to https://github.com/swiftlang/swift-testing/blob/66c32ae6c4f87b88c96cd6f16e6e92538177617e/Sources/Testing/Traits/Trait.swift#L57 where the availability of the trait object is noted as:

  /// @Metadata {
  ///   @Available(Swift, introduced: 6.1)
  ///   @Available(Xcode, introduced: 16.3)
  /// }

I've tested this on my project and it seems to work as expected.

@Archdoog Archdoog marked this pull request as ready for review March 23, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant