I'm struggling with using Xcode to develop my SPM project. swift test from the command line can build and run the test, but Xcode chokes on @testable import CLI. I think it has to do with how my product, target, and directory names don’t precisely match (in that Xcode is probably making some assumption somewhere).

Package.swift:

// swift-tools-version: 5.10

import PackageDescription

let package = Package(
	name: "Raise3D",
	platforms: [.macOS(.v13)],
	products:
	[
		.library(name: "Raise3DAPI", targets: ["Raise3DAPI"]),
		.executable(name: "raise3d", targets: ["CLI"])
	],
	dependencies:
	[
		.package(url: "https://github.com/apple/swift-argument-parser",		from: "1.0.0"),
		.package(url: "https://github.com/apple/swift-docc-plugin",			from: "1.0.0"),
//		.package(url: "https://github.com/apple/swift-testing.git",			from: "0.7.0"),
	],
	targets:
	[
		.target(name: "Raise3DAPI", path: "Sources/API"),
		.executableTarget(
			name: "CLI",
			dependencies:
			[
				.product(name: "ArgumentParser", 			package: "swift-argument-parser"),
				.target(name: "Raise3DAPI"),
			]),
		.testTarget(
			name: "CLITests",
			dependencies:
			[
				.target(name: "CLI"),
//				.product(name: "Testing",					package: "swift-testing"),
			]
		)
	]
)

My test file:

import Foundation
import XCTest

@testable import CLI  // No such module 'CLI'


class
CLITests : XCTestCase
{
	func
	testNotify()
	{
		var monitor = Monitor()
		monitor.check(jobStatus: .running, runningStatus: .running)
	}
}

It gets worse. If I import as @testable import raise3d, the code compiles with the compile command, but attempting to run the unit test fails with

Undefined symbols for architecture arm64:
  "raise3d.Monitor.check(jobStatus: Raise3DAPI.Raise3DAPI.JobInformation.Status, runningStatus: Raise3DAPI.Raise3DAPI.RunningStatus.Status) -> ()", referenced from:
      CLITests.CLITests.testNotify() -> () in CLITests.o
  "raise3d.Monitor.init() -> raise3d.Monitor", referenced from:
      CLITests.CLITests.testNotify() -> () in CLITests.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

and if I try swift test:

% swift test
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
…/CLITests.swift:11:18: error: no such module 'raise3d'
@testable import raise3d
                 ^
…/CLITests.swift:11:18: error: no such module 'raise3d'
@testable import raise3d
                 ^
error: fatalError

error: fatalError

Probably that's the reason... I've just checked one of my projects that has same structure - lib + cli executable, and tests are running OK. Xcode: Version 15.3 (15E5202a)