Anyone else having trouble getting Xcode to expand nested Swift macros? The outer macro expands fine, but when I try to expand the inner macro it just beeps.
My macro is used like this:
@ThrowingImplementation(MyError.unimplemented)
protocol MyProtocol {
func something() throws
}
expanding first to this:
@ThrowingExtension(MyError.unimplemented)
protocol ThrowingMyProtocol: MyProtocol {
// func something() throws
}
...which is supposed to expand to this:
extension ThrowingMyProtocol {
func something() throws { throw MyError.unimplemented }
}
but I can't get Xcode to expand this second macro.
I have to use a nested macro because only an extension macro can introduce an extension. The function is included as a comment so the extension macro can see it. I have unit tests for both macros, and in the tests everything is fine.
My problem is that, in some cases, when I do struct MyThing: ThrowingMyProtocol {}
I get an error that it does not conform to MyProtocol
even though that macro-generated extension should have taken care of implementing all functions. Not being able to expand the nested macro makes it hard to diagnose why this is happening.
(this is with Xcode 15.0.1)