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
Running swift build --explicit-target-dependency-import-check=error
with the new --enable-experimental-prebuilts
fails checking dependencies for macro targets in projects which use custom macros such as swiftlang/swift-testing or when depending on another project introducing custom macros such as pointfreeco/swift-dependencies.
Expected behavior
The project, provided that it only import
s modules which are also included in the target dependency graph of the package file, should build with no errors, just like it does when omitting the --explicit-target-dependency-import-check
option.
Actual behavior
The build produces errors from the dependency check:
error: Target TestingMacros imports another target (SwiftDiagnostics) in the package without declaring it a dependency.
error: Target TestingMacrosTests imports another target (SwiftSyntaxMacros) in the package without declaring it a dependency.
(In fact, it randomly varies by build which missing dependency it lists above.)
Steps to reproduce
- Clone https://github.com/swiftlang/swift-testing.
- Check out tag 6.1.1 (because main uses a version of Swift Syntax which isn't prebuilt yet!).
- Run
swift build --explicit-target-dependency-import-check=error --enable-experimental-prebuilts
.
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 Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020