Skip to content

"error: missing required module 'SwiftCompilerPlugin'" with swift-syntax prebuilts enabled #9381

@noremac

Description

@noremac

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 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

  1. Ensure prebuilts are enabled.
  2. Clone this example repo: MyMacroPrebuiltFailureExample
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions