the store(in: self.cancelables) is not the problem. Making sure cancellable exists, is.
I wanted to check if the class has a cancellables property, otherwise add it. But this is not possible as I only have inspection capabilities to the member somePublisher and not the container it's included on.
It's a fundamental property of macros that the compiler only exposes certain information to them. While it's in theory possible for us to add APIs to the MacroExpansionContext to expose more information, this takes a lot of careful engineering, and the more information we expose, the more it impacts the efficiency of tools (particularly features like code completion). As of yet, there's no way to just query an arbitrary type—even an enclosing type—and see all of its contents.
This means you often have to either figure out a place where you can attach a macro so that it can see what it needs, or you need to make assumptions about the environment and let the compiler diagnose a normal error if those assumptions are wrong.
What I would recommmend is that you make @Cancelable be an attached member macro you apply to the type. It will add both the cancellables property and an addCancelable(_:) method that you can use like this:
For the cancellable stuff you could try doing something similar to what RxSwift did and create some sort of cancellable container like their DisposeBag and extend cancellable to have a cancelled(by: cancelContainer). Your macro could simple add the container as an attribute to the type owning the Publishers. It’s not perfect but will save a bunch of repetition with redeclaring the cancellable variables a the time.