I ended up having to add the swift-syntax packages as depends in the module where I use the macro. Something like this...
let package = Package(
name: "MyPackage",
platforms: [
.iOS(.v17),
.watchOS(.v10),
.macOS(.v14)
],
products: [
.library(
name: "MyPackage",
targets: [
"MainTarget",
"MyMacro"
]
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax", revision: "d3a39e42038b59e65186cadcd22467943e0bab8e"),
],
targets: [
.macro(
name: "MyMacroMacros",
dependencies: [
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
]
),
.target(
name: "MyMacro",
dependencies: [
"MyMacroMacros"
],
),
.target(
name: "MainTarget",
dependencies: [
"MyMacro",
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
],
),
.testTarget(
name: "MainTargetTests",
dependencies: [
"MainTarget",
"MyMacro",
"MyMacroMacros",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
],
),
.testTarget(
name: "MyMacroTests",
dependencies: [
"MyMacroMacros",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
]
),
]
)
the change that fixed things was adding the swift syntax dependencies to the MainTarget target