Temporary fix of SwiftPM Bug using task.sh
Some checks failed
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled

SwiftPM has currently a bug, that products or targets of dependencies
are taken into consideration when resolving names, regardless if they're
used or not by the root package. This stops Swift PM from working on packages,
that declare this package as a dependency and define their own TaskCLI target,
as they collide with the definitions of this package. This is resolved, by
prefixing TaskCLI with the package name.
The product collision - which causes swift run - to run this package's task
executable is resolved, by adding that product only temporarily during task
execution using task.sh.

See https://github.com/swiftlang/swift-package-manager/issues/8482
This commit is contained in:
T. R. Bernstein
2026-03-16 16:37:15 +01:00
parent 134e4e152d
commit 63cb653ad2
4 changed files with 71 additions and 10 deletions

View File

@@ -8,10 +8,6 @@ let package = Package(
.library(
name: "Inotify",
targets: ["Inotify"]
),
.executable(
name: "task",
targets: ["TaskCLI"]
)
],
dependencies: [
@@ -42,7 +38,7 @@ let package = Package(
],
),
.executableTarget(
name: "TaskCLI",
name: "InotifyTaskCLI",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
@@ -50,7 +46,8 @@ let package = Package(
.product(name: "_NIOFileSystem", package: "swift-nio"),
.product(name: "Subprocess", package: "swift-subprocess"),
.product(name: "Noora", package: "Noora")
]
],
path: "Sources/TaskCLI"
)
]
)