Can Swift Packages be optional?

I work with a number of enterprise clients and one thing we often do is have various frameworks that are optional depending on what type of build we are doing. A common example being to include a framework that contains an embedded server for testing, demo or debugging purposes.

Prior to SPM we would link those frameworks as "Optional" and run a script phase after the build that removed them from the Frameworks directory of the app if it was a "Release" build.

Now I have an Xcode project that includes a number of SPM package, one of which is an embedded server which in turns references several other packages I'd like to exclude form a "Release" build.

But I cannot figure out how to do this. Can I make the inclusion of a package optional? Or somehow remove it after linking?

In Swift I can write #if canImport(MockServer) but I cannot see how to actually make MockServer an optional include.

Any ideas?

Can Swift Packages be optional?
 
 
Q