I have protocols defined in 'interface' targets. I have separate targets for mocks. I want to use Swift Macros to generate mock classes that conform to protocols. It's imperative that the declarations of the mocks and protocols are in separate targets. Is this possible?
Interface target:
protocol SomethingDoer {
func doSomething()
}
Mocks target:
import Interface
// I know freestanding declarations aren't allowed on the top level but that's
// besides the point of the question
#generateMock(for: SomethingDoer) // expands to the class below
final class SomethingDoerMock: SomethingDoer {
var doSomethingCallsCount = 0
func doSomething() {
doSomethingCallsCount += 1
}
}
The requirement for the protocol and mock to be in separate targets means I cannot use attached macros. I've tried my best to get this working with freestanding macros but couldn't. Is this currently possible? If so, how? Any help would be greatly appreciated