Description
Is it reproducible with SwiftPM command-line tools: swift build
, swift test
, swift package
etc?
- Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands,
swift build
,swift test
,swift package
etc.
Description
When an executable target is referenced by both a product and a plugin dependency, SPM fails with "no product named 'TargetName'" error, even though the plugin should be able to depend on the target directly.
Expected behavior
The plugin should be able to depend on the executable target directly, regardless of whether it's used by a product.
Actual behavior
Build fails with: error: no product named 'MyExecutableTarget'
Steps to reproduce
Create a package with this structure:
products: [
.executable(name: "my-tool", targets: ["MyExecutableTarget"]),
.plugin(name: "my-plugin", targets: ["MyPlugin"]),
],
targets: [
.executableTarget(name: "MyExecutableTarget", dependencies: [...]),
.plugin(
name: "MyPlugin",
capability: .buildTool(),
dependencies: ["MyExecutableTarget"]
),
]
Workaround
Create a duplicate product with the target's name:
products: [
.executable(name: "my-tool", targets: ["MyExecutableTarget"]),
.executable(name: "MyExecutableTarget", targets: ["MyExecutableTarget"]), // Workaround
.plugin(name: "my-plugin", targets: ["MyPlugin"]),
]
Swift Package Manager version/commit hash
Swift Package Manager - Swift 6.1.0
Swift & OS version (output of swift --version ; uname -a
)
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0
Darwin Mac 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:43 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8132 arm64