Building and testing several packages in the same SPM repo

Dear community, I have a setup where I host several target under the same package. I'm working on CI solution to be able build and test those targets (lets simplify the case and talk only on iOS for the moment).

The issue that I'm running into is fully described and reproducible in this git repo - GitHub - danibachar/SPM-Multi-Package: This repo shows two SPM setups, that on the multi package one, we cannot run xcodebuild tests per each target.

I have a simple Swift Package, called SinglePackage, it has one Package.swift file, one class and one test. Inside my SinglePackage root folder I run the following commands

  • swift package resolve
  • xcodebuild -scheme SinglePackage -destination 'platform=iOS Simulator,id=4BE845BA-AE9E-4F53-B2FB-A5415C89950B' build test (I got the platform from running the same command without the platform flag and checking what platforms are available on my mac. The scheme I got from running xcodebuild -list -json)

Everything build and tests great!

I have another Package, called MultiPackage, with one Package.swift file, and two folder/classes under the Sources folder. Each one corresponds to a separate target. When I run xcodebuild -list -json I get several targets as expected

  "workspace" : {
    "name" : "MultiPackage",
    "schemes" : [

Now, I know I can use the MultiPackage-Package scheme to build and run tests over all the targets in the pacakge. But what if I want to test packages individually? If I run

  • xcodebuild -scheme MultiPackage1 -destination 'platform=iOS Simulator,id=4BE845BA-AE9E-4F53-B2FB-A5415C89950B' build test. I get the following error
    xcodebuild: error: Scheme MultiPackage1 is not currently configured for the test action.

I can still build those package while omitting the test sub command.

But still, what if I want to test each target individually? It seems like Ill have to generate the Pacakge.swift file on the fly, or separate and provide a Package.swift file for each "package/target' -