# Error: no such module 'Testing'

**URL:** <https://forums.swift.org/t/error-no-such-module-testing/74784>\
**Category:** Using Swift\
**Tags:** packagemanager, swift-testing\
**Created:** [September 20, 2024, 4:16pm UTC](https://forums.swift.org/t/error-no-such-module-testing/74784 "2024-09-20T16:16:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Q-Bert](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/q-bert/32/19862_2.png) [@Q-Bert](https://forums.swift.org/u/Q-Bert)\
**Post date:** [September 20, 2024, 4:16pm UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/1 "2024-09-20T16:16:47Z")

</div>

1. I've updated the Swift Toolchain:

```swift
$ 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](https://www.swift.org/blog/announcing-swift-6/#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
// swift-tools-version:6.0
// …

```

4. I've followed [step-by-step instructions](https://swiftpackageindex.com/swiftlang/swift-testing/main/documentation/testing/migratingfromxctest) 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.

---

<div class="post-metadata">

**Author:** ![wes1](https://avatars.discourse-cdn.com/v4/letter/w/848f3c/32.png) [@wes1](https://forums.swift.org/u/wes1)\
**Post date:** [September 20, 2024, 5:47pm UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/2 "2024-09-20T17:47:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![smontgomery](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/smontgomery/32/965_2.png) [@smontgomery](https://forums.swift.org/u/smontgomery)\
**Post date:** [September 20, 2024, 7:24pm UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/3 "2024-09-20T19:24:25Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![smontgomery](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/smontgomery/32/965_2.png) [@smontgomery](https://forums.swift.org/u/smontgomery)\
**Post date:** [September 20, 2024, 10:00pm UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/4 "2024-09-20T22:00:32Z")

</div>

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](https://github.com/swiftlang/swift-package-manager/pull/7840/files#diff-adf7999cea9f76ad6a7d320c04fbfa7222d4c7d20bd27f81667c02cf88081897R414) 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](https://www.swift.org/install/macos/) and use a Swift 6 macOS toolchain from [Swift.org](http://Swift.org), things should work as expected.

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [September 20, 2024, 10:25pm UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/5 "2024-09-20T22:25:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [September 21, 2024, 12:24am UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/6 "2024-09-21T00:24:02Z")

</div>

> [@smontgomery](#):
>
> but in the mean time, if you instead [download](https://www.swift.org/install/macos/) and use a Swift 6 macOS toolchain from [Swift.org](http://Swift.org), things should work as expected.

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](https://github.com/swiftlang/swift/issues/76534)) that require the Xcode toolchain to compile successfully, as they encounter compiler crashes when using any other toolchain.

---

<div class="post-metadata">

**Author:** ![smontgomery](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/smontgomery/32/965_2.png) [@smontgomery](https://forums.swift.org/u/smontgomery)\
**Post date:** [September 23, 2024, 5:49pm UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/7 "2024-09-23T17:49:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rdrsss](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rdrsss/32/38511_2.png) [@rdrsss](https://forums.swift.org/u/rdrsss)\
**Post date:** [December 8, 2024, 3:17am UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/8 "2024-12-08T03:17:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rdrsss](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rdrsss/32/38511_2.png) [@rdrsss](https://forums.swift.org/u/rdrsss)\
**Post date:** [December 9, 2024, 1:23am UTC](https://forums.swift.org/t/error-no-such-module-testing/74784/9 "2024-12-09T01:23:25Z")

</div>

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 🫡
