-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 packageetc.
Description
I have some macro testing code that fails to compile when swift-syntax prebuilts are enabled. This seems to be the result of using swift-macro-testing instead of swift-syntax's built in testing library. I have created an example repo to demonstrate the issue. It is the standard MyMacro example starter project provided by Xcode, but modified to use the swift-macro-testing library. It builds and runs tests successfully when prebuilts are disabled but fails with error: missing required module 'SwiftCompilerPlugin' when they are enabled.
Expected behavior
I would expect these tests to compile and run when swift-syntax prebuilts are enabled.
Actual behavior
I receive the following error after running swift test:
error: emit-module command failed with exit code 1 (use -v to see invocation)
/Users/noremac/Desktop/MyMacroPrebuiltFailureExample/Tests/MyMacroTests/MyMacroTests.swift:2:8: error: missing required module 'SwiftCompilerPlugin'
1 | #if canImport(MyMacroMacros)
2 | import MyMacroMacros
| `- error: missing required module 'SwiftCompilerPlugin'
3 | import MacroTesting
4 | import SnapshotTesting
/Users/noremac/Desktop/MyMacroPrebuiltFailureExample/Tests/MyMacroTests/MyMacroTests.swift:2:8: error: missing required module 'SwiftCompilerPlugin'
1 | #if canImport(MyMacroMacros)
2 | import MyMacroMacros
| `- error: missing required module 'SwiftCompilerPlugin'
3 | import MacroTesting
4 | import SnapshotTesting
error: fatalError
Steps to reproduce
- Ensure prebuilts are enabled.
- Clone this example repo: MyMacroPrebuiltFailureExample
- Run
swift test
Swift Package Manager version/commit hash
Xcode 26.1.1 (not sure what to put)
Swift & OS version (output of swift --version ; uname -a)
swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Target: arm64-apple-macosx26.0
Darwin Air.local 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:03 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T8112 arm64