Syntax highlighting from a peer macro

I've created a peer macro which outputs a suffixed name

@attached(peer, names: suffixed(MySuffix))

But in Xcode the code it outputs doesn't get any syntax highlightng and is just some bland black on white text.

Is there something I need to opt in to to get this highlighting? Or is this just a current limitation of Swift macros?

1 Like

Are you talking about the code that’s shown if you select “Expand Macro”. That could should have syntax coloring. Do you have a full example where it doesn’t?

Hey Alex!

I mean in the case of using the type created by the macro in my code, not expanding it.

My macro is a peer macro with a suffix name defined on it and creates let’s say MyTypeProtocolWitness but whenever I use that type in my code it doesn’t get the syntax highlighting.

My macro code is still WIP but can be seen on this GitHub repo

But the main bit of code is the macro definition:

@attached(peer, names: suffixed(ProtocolWitness))
public macro ProtocolWitnessable(targetType: TargetType = .struct, attributeNames: [String] = []) = #externalMacro(module: "ProtocolWitnessableMacros", type: "ProtocolWitnessableMacro")

public enum TargetType {
    case `struct`
    case `class`
}

It’s worth noting I also had this issue before adding arguments to the macro definition