Error: no such module 'Testing'

  1. I've updated the Swift Toolchain:
    $ swift -version
    swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
    Target: arm64-apple-macosx15.0
    
  2. Swift 6 supposedly now includes Swift-Testing; It is no longer necessary to add swift-testing into a Package.swift. (Since it's already part of the toolchain).
  3. I've updated my Package.swift file to reflect the new toolchain:
    // swift-tools-version:6.0
    // …
    
  4. I've followed step-by-step instructions to migrate every — just two really — previously functioning XCTests to Swift-Testing.
  5. And yet, running swift test gives me error: no such module 'Testing'

Have I made a gross oversight?! Am I missing something?!
I would greatly appreciate if someone could show me what am I missing or misunderstanding?!? Thank you!

  • I've tried swift package reset… doesn't help.

FWIW, using the same version of Swift I created a small package and the test ran fine using swift test, in both the default v5 and new v6 swift mode.

A separate issue: I also tried using import Testing and @Test in the main executable to see if that's the mistake you were making. That compiles happily but then at runtime crashes on failure to load the library. Urk!

@Q-Bert Are you able to share the build log showing this error, preferably with verbose logging enabled? Feel free to private message that to me if needed.

After reviewing your build log offline, it appears you're using the copy of the swift test tool included in the "CommandLineTools" package on macOS. The swift test tool is part of Swift Package Manager, and the version of SwiftPM in CommandLineTools does not yet have this change landed on main which configures the necessary search paths to locate Testing.framework within the CommandLineTools SDK.

A future CommandLineTools package should receive that update, but in the mean time, if you instead download and use a Swift 6 macOS toolchain from Swift.org, things should work as expected.

1 Like

Wait, it's not the same version that's included with Xcode? In that case, if they set Xcode as the active developer tools, wouldn't it use the version from Xcode?

are there any plans to distribute a downloadable toolchain for macOS that does not have compiler assertions enabled (similar to the linux toolchains)?

there exists a surprisingly high percentage of ecosystem packages (including it seems, SwiftSyntax) that require the Xcode toolchain to compile successfully, as they encounter compiler crashes when using any other toolchain.

1 Like

Yes, I expect that using the copy of swift test in Xcode 16 would resolve this as well.