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
I have a buildCommand that generates a Swift file, and optionally some resources.
The generated files are written to the correct place, and can be used by the client of the plugin.
However, some intermediate files seem to sometimes be written to the current working directory, instead of the .build folder.
Specifically, for a generated file called Version.generated.swift
, I am seeing the following files appear in the working directory:
Version.generated.o
Version.generated.swiftdeps
Version.generated.swiftdeps~
Version.generated.d
This does not seem to happen every time, but I've yet to establish the trigger. A race condition perhaps?
Expected behavior
Generated files are written into a plugin/target specific folder inside .build.
Any resulting intermediates go to the normal places inside .build.
Actual behavior
Generated files are written into a plugin/target specific folder inside .build.
Resulting intermediates sometimes leak into the working directory.
Sometimes the build produces an error (but not always)

Steps to reproduce
clone https://github.com/elegantchaos/ReleaseTools.git
checkout commit 7944ebb942e7681b44b00e25cc88837f23d31baf
swift run rt --help
Swift Package Manager version/commit hash
Swift Package Manager - Swift 6.0.0-dev
Swift & OS version (output of swift --version ; uname -a
)
swift-driver version: 1.113 Apple Swift version 6.0 (swiftlang-6.0.0.7.6 clang-1600.0.24.1)
Target: arm64-apple-macosx14.0
Darwin space-monster.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 arm64