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

@@ -132,11 +132,14 @@ try inotify.removeWatch(wd)
## Build Tool
The package ships with a `task` executable (the `TaskCLI` target) that serves as the project's build tool. It automates running tests and generating documentation inside Linux Docker containers, so you can validate everything on the correct platform even when developing on macOS.
Because of a Swift Package Manager Bug in the [package dependency resolution][swiftpm-bug], the executable needs to be run using the `task.sh` shell script.
[swiftpm-bug]: https://github.com/swiftlang/swift-package-manager/issues/8482
### Tests
```bash
swift run task test
./task.sh test
```
Use `-v`, `-vv`, or `-vvv` to increase log verbosity. The command runs two passes: first all tests except `InotifyLimitTests`, then only `InotifyLimitTests` (which manipulate system-level inotify limits and need to run in isolation).
@@ -148,7 +151,7 @@ Docker must be installed and running on your machine.
Full API documentation is available as DocC catalogs bundled with the package. Generate them locally with:
```bash
swift run task generate-docs
./task.sh generate-docs
```
Then open the files in the newly created `public` folder.