No way to add an extension to a type I don't own

Peer macros cannot introduce extensions. Extension macros can only be applied to primary declarations. The combination of these two facts means that if I have, say, a type that interacts with SwiftUI in some way, and I want to add an extension on View that uses that type, it's just not possible.

Or am I missing something?

I think not since if it was possible, this environment value macro would use such a technique. Don't get me wrong - the solution in that repo is clever, just not always usable...

1 Like