0

Working with Xcode. I got framework A. I would like to create a framework A_intercept; which implements the same exported API functions from A and will eventually forward the same function calls to A. So I create A_intercept, and added A to the linked frameworks in "Link Binary with Libraries"

Now, I got some function M in A, A_intercept, will also implement it and name it M as well so it could be intercepted; however, How then A_interecept can forward the call to A; wouldn't that be a recursive call?

sramij
  • 4,775
  • 5
  • 33
  • 55
  • You're going to need to do symbol re-writing. You can use a ld script to prefix all the symbols in library A, and then implement the real symbols in library B. But be aware that anything that uses strings (`dlsym`, `NSClassFromString`) will have problems. There's unfortunately not really a way to do this at runtime. You *can* do it on the simulator only with mach_override (see https://github.com/richardjrossiii/mach_override_example), but if you're looking to use this in production you're looking in the wrong place. – Richard J. Ross III May 23 '17 at 23:40
  • See https://stackoverflow.com/questions/10157680/how-can-i-get-gcc-to-add-a-prefix-to-all-symbol-names – Richard J. Ross III May 23 '17 at 23:41
  • Thanks @RichardJ.RossIII ; I was wondering if there someway to accomplish that w/o messing with A, given that ObjC runtime keeps surprising me with ticks could be done with it. This is not a production code though. – sramij May 24 '17 at 00:49
  • You can do that easily with the Objective-C runtime environment. But *functions* are not dispatched by the RTE, but called directly. *Messages* are dispatched to *methods*. – Amin Negm-Awad May 24 '17 at 03:40

0 Answers0