Closed coppercash closed 8 years ago
Aspects does some heavy tricks and is incompatible with other libraries that do the same, such as JSPatch or ReactiveCocoa. The only way to solve this is to completely change the way it works, e.g. in my 1.5 branch that requires assembly and trampolines.
I'm just using it for tests and do not recommend shipping it in apps.
But I believe many people regard Aspects as the only AOP solution for ObjC just as I do. It is too bad to heard the denial from its own auther.
Sorry to break the news :)
I am using a lib named JSPatch and Apects at the same time. It swizzles methods to
_objc_msgForward
and(SEL)forwardInvocation:
to customIMP
just as Aspects does.My Case
The method
map<SEL, IMP>
of the superclass, in which the methodfoo
is swizzled by JSPatch:The method
map<SEL, IMP>
of the subclass, in which the methodbar
is swizzled by Aspects:Pseudo-callstack
SubClass
calles methodfoo
SubClass
dosen't implement methodfoo
, so the implementation ofSuperClass
is usedSuperClass.foo
is redirected to_objc_msgForward
by JSPatchMethod
forwardInvocation
is added ontoSubclass
by Aspects, it is calledSubClass.forwardInvocation
points to__ASPECTS_ARE_BEING_CALLED__
__ASPECTS_ARE_BEING_CALLED__
tries to find method namedaspects__foo
in the inheritance, which apparently is impossible. Thus, it throws the exception.Solution
Alter
to
Aspects breaks the inheritance of method
forwardInvocation:
, my solution is to add it back. On the other hand, I am worrying how it will affect other cases. However, it will crashes anyway, why not give it a chance to see if the superclass is capable to take over.