In my project, I've broken out some components into local SPM packages. In Xcode, I've added these packages and the project compiles as expected. The SPM's have unit tests in a .testTarget and when I run swift test
, the unit tests all run.
I'd like to run the tests for the local SPMs when I run unit tests in the Xcode project (cmd-U). I've got a single test plan with all the unit tests from the project file. According to "the internet", I should be able to add the SPM tests to the test plan with the + button. But that doesn't work for me. In the screenshot below, the ByteToolBox entry is a local SPM with tests, but I can't select it. It feels like there should be a test target entry below ByteToolBox like the GlowWormTests entry under the GlowWorm project.
This is the super simple Package.swift for ByteToolBox:
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "ByteToolBox",
platforms: [.macOS(.v13)],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "ByteToolBox",
targets: ["ByteToolBox"]
),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(name: "ByteToolBox"),
.testTarget(
name: "ByteToolBoxTests",
dependencies: ["ByteToolBox"]
),
]
)
I'm at a bit of a loss here. Most of the instructions for this just gloss over the 'add the test target' step as though it just works.
Xcode 15.3
macOS 14.4.1