Build error when including multiple Swift-syntax macros: Multiple commands produce …

We have a large multi-module project which I'm attempting to introduce SwiftMacros to in order to reduce some boilerplate. In the workspace I have 3 SPM package where I've added macros, making sure the each module only contains the macros relevant to the purpose of that module.

In the Package.swift files I've added `swift-syntax in dependencies:

dependencies: [
    .package(url: "https://github.com/swiftlang/swift-syntax", from: "510.0.0"),
    ],

And then in a macro target:

.macro(
    name: "ToolboxMacros",
    dependencies: [
        .product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
        .product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
    ],
    path: "Sources/Macros"
),

Individually I write, debug and test those macros and the code that uses them without an issue.

However when I attempt to compile the app itself (including the packages with macros) it fails with errors on every Swift-Syntax modules like this

Prepare build
error: Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftDiagnostics.framework/Versions/A/SwiftDiagnostics'
    note: Target 'FlagDataMacros' (project 'FeatureFlagsMacros') has copy command from '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/PackageFrameworks/SwiftDiagnostics.framework' to '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftDiagnostics.framework'
    note: Target 'ToolboxMacros' (project 'Toolbox') has copy command from '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/PackageFrameworks/SwiftDiagnostics.framework' to '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftDiagnostics.framework'
    note: Target 'ToolboxUIMacros' (project 'ToolboxUI') has copy command from '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/PackageFrameworks/SwiftDiagnostics.framework' to '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftDiagnostics.framework'
error: Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftParser.framework'
…
etc, etc

And so on for every module in Swift-syntax. Then it's followed by:

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftBasicFormat.framework'

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftBasicFormat.framework/Versions/A'

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftBasicFormat.framework/Versions/A/SwiftBasicFormat'

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftCompilerPlugin_639CE4BF99800FCA_PackageProduct.framework'

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftCompilerPlugin_639CE4BF99800FCA_PackageProduct.framework/Versions/A'

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftCompilerPlugin_639CE4BF99800FCA_PackageProduct.framework/Versions/A/SwiftCompilerPlugin_639CE4BF99800FCA_PackageProduct'

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftDiagnostics.framework'

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftDiagnostics.framework/Versions/A'

Multiple commands produce '/Users/clarkson/Library/Developer/Xcode/DerivedData/Medibank-fqrwypscprflcvfjhncnoonbjtzn/Build/Products/Debug/Frameworks/SwiftDiagnostics.framework/Versions/A/SwiftDiagnostics'
…
etc, etc

Does anyone know how I can resolve this because the only thing I can think of is to create a single macro package, however I'd rather associate the macros with their correct modules rather than creating one global macro package.

Build error when including multiple Swift-syntax macros: Multiple commands produce …
 
 
Q