Search code examples
iosxcodedyld

iOS tools for debugging dynamic libraries


I am trying to understand how dynamic linking works on iOS 8 and would like to print the location of the resolved libraries when the app launches. Are there any tools for doing this? In crash reports when a dylib is not found there is some info about search paths, but I can't find this info in a non-crashing execution.

Specifically, I am trying to understand a scenario which is working, but which I didn't think would:

  • Swift Framework (Foo): Dynamic Library Install Name is @rpath/Foo.framework/Foo
  • Swift app (Bar): Runtime Search Paths is @executable_path/Frameworks

The app does NOT have any Embedded Binaries (General -> Embedded Binaries), and does NOT embed the framework as a bundle resource (Build Phases -> Copy Bundle Resources).

In the generated Bar.app folder there is a Frameworks directory, but it does not contain Foo, and Foo is not contained anywhere else within Bar.app. I do not see how is it possible for Foo to be resolved since the framework is embedded and should be unavailable?


Solution

  • I found what I was looking for, as documented by Apple under a document called Technical Note TN2239 iOS Debugging Magic. In this document there is a section describing various environment variables that can bet set which will force the dynamic linker to write out useful debugging information.

    After setting these variables in Xcode (Edit Scheme -> Run -> Arguments -> Environment Variables) I get detailed information about how and what the linker is resolving to.