Swift-testing Package.swift best practice for Linux/Non-Apple support

Hi, I noticed that the macOS tools (16A5211f) does not require a Package.swift to have swift-testing as a dependency to run tests via the command line, but the current Linux nightly does (08-02)

Presumably this is so a package on Linux doesn't pull swift-syntax unless explicitly called. Great! Love the opt-in.

However, what is the current best practice for a package to support both? To just include the dependency because macOS will figure it out (ideally if it's local one matches it won't recompile?) or to conditionally include the dependency depending on non-Apple platform detection?

If the later, anyone have an example they like? I'm trying to figure out if I need to add the test(s) by hand as well or how to just insert the dependency into items that where==.testTarget or some such.

Thanks!

1 Like

Xcode 16 includes a copy of Swift Testing, so the package dependency is not needed on macOS. We are working to add Swift Testing to the Swift 6 toolchain; when that work is complete, it will not be necessary to include a package dependency on Swift Testing on Linux/Windows either.

4 Likes

w00t! Thanks!