Using an enum inside an attached macro

I want to use an enum in a macro definition to enhance the user experience.

I have created an attached macro around the standard swift-log package. The initial version of the macro (without the enum) works as expected, both in test-cases and in the test client.

The software is organized according to the structure as defined by swift package --type macro:

├── Package.swift
├── Sources
│   ├── Macro
│   │   └── Macro.swift
│   ├── MacroClient
│   │   └── main.swift
│   └── MacroMacros
│       └── MacroMacro.swift

The enum I want to use is named MacroEnum and needs to be known both by the declaration of the macro inside Macro and by the implementation of the macro in the MacroMacros.

Given that MacroMacros is a dependency on Macro, the enum has to be stored inside MacroMacros and then imported in Macro.

However this approach does not work for a client of the macro. The expansion of the macro uses the enum and is unknown because the internals of MacroMacros are not exposed.

I can solve this by storing the enum in a separate package but that makes that you always have to import both the dependency and the macro which feels wrong. Another solution could be to store the enum inside Macro and have a private copy of the enum inside MacroMacros which feels complete wrong and error prone. MacroMacros cannot import Macro because this will cause a circular dependency error.

Any advise on how to approach this would be appreciated.

I agree this approach feels clowny… but it's also the approach I went with.

I am hoping for another solution. But if that is the only option, so be it.