$ 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
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).
I've updated my Package.swift file to reflect the new toolchain:
// swift-tools-version:6.0
// …
I've followed step-by-step instructions to migrate every — just two really — previously functioning XCTests to Swift-Testing.
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!
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.
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.
Hello, I'm seeing this exact error as well, running swift test
Installed xcode Version 16.1 (16B40) swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4) Target: arm64-apple-macosx15.0
I've also tried with swift test --enable-swift-testing to no avail as well.
Okay sorry everyone, I was able to solve it. Looked at the SPM docs around this package and saw the line around development toolchain. Not wanting to switch my daily driver over, I followed the package steps instead.
I went ahead and added the .package(url: "https://github.com/swiftlang/swift-testing.git", branch: "main"), to my dependencies and then .product(name: "Testing", package: "swift-testing"), to my test target, and voila it works! also had to run xcode-select -switch /Applications/Xcode.app/Contents/Developer but yeah excited to get started with this. Grazie