I’m trying to extend the functionality of PointFree's DependencyClientMacro
to also add the TestDependencyKey
conformance to the client and I’m having trouble on the linking phase of my plugin module.
In my macro code I added this:
import DependenciesMacrosPlugin
extension AMDependencyClientMacro: MemberAttributeMacro {
public static func expansion(
of node: AttributeSyntax,
attachedTo declaration: some DeclGroupSyntax,
providingAttributesFor member: some DeclSyntaxProtocol,
in context: some MacroExpansionContext
) throws -> [AttributeSyntax] {
try DependencyClientMacro.expansion(
of: node,
attachedTo: declaration,
providingAttributesFor: member,
in: context
)
}
}
extension AMDependenciesMacros: MemberMacro {
public static func expansion(
of node: AttributeSyntax,
providingMembersOf declaration: some DeclGroupSyntax,
in context: some MacroExpansionContext
) throws -> [DeclSyntax] {
try DependencyClientMacro.expansion(
of: node,
providingMembersOf: declaration,
in: context
)
}
}
In Packages.swift
I added PointFree's library as a dependency:
.macro(
name: "AMDependenciesMacros",
dependencies: [
.product(name: "DependenciesMacros", package: "swift-dependencies"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
]
),
When I build compilation works fine but linking fails:
Undefined symbols for architecture arm64:
"static DependenciesMacrosPlugin.DependencyClientMacro.expansion<A, B, C where A: SwiftSyntax.DeclGroupSyntax, B: SwiftSyntax.DeclSyntaxProtocol, C: SwiftSyntaxMacros.MacroExpansionContext>(of: SwiftSyntax.AttributeSyntax, attachedTo: A, providingAttributesFor: B, in: C) throws -> [SwiftSyntax.AttributeSyntax]", referenced from:
static AMDependenciesMacros.AMDependencyClientMacro.expansion<A, B, C where A: SwiftSyntax.DeclGroupSyntax, B: SwiftSyntax.DeclSyntaxProtocol, C: SwiftSyntaxMacros.MacroExpansionContext>(of: SwiftSyntax.AttributeSyntax, attachedTo: A, providingAttributesFor: B, in: C) throws -> [SwiftSyntax.AttributeSyntax] in AMDependencyClientMacro.o
"static DependenciesMacrosPlugin.DependencyClientMacro.expansion<A, B where A: SwiftSyntax.DeclGroupSyntax, B: SwiftSyntaxMacros.MacroExpansionContext>(of: SwiftSyntax.AttributeSyntax, providingMembersOf: A, in: B) throws -> [SwiftSyntax.DeclSyntax]", referenced from:
static AMDependenciesMacros.AMDependenciesMacros.expansion<A, B where A: SwiftSyntax.DeclGroupSyntax, B: SwiftSyntaxMacros.MacroExpansionContext>(of: SwiftSyntax.AttributeSyntax, providingMembersOf: A, in: B) throws -> [SwiftSyntax.DeclSyntax] in AMDependencyClientMacro.o
What am I missing? The original macro code has everything as public so I'd expect it to work. Anything else I need to add to my macro
definition in Packages.swift
Thanks.