14

I have an app, call it Animal.app. Inside its Contents/Frameworks folder is a framework, say Mammal.framework. And inside the Versions/A/Frameworks folder of the framework, I have dog.dylib. The install name of dog.dylib is @rpath/dog.dylib. For the "Runpath Search Paths" setting of the framework, I have specified @loader_path/../Frameworks. (My reasoning for that last setting is that the "loader" of the dylib would be the binary of the framework, at the path Mammal.framework/Versions/A/Mammal.)

I get an error message at runtime:

Dyld Error Message:
  Library not loaded: @rpath/dog.dylib
  Referenced from: /Volumes/VOLUME/*/Animal.app/Contents/MacOS/../Frameworks/Mammal.framework/Versions/A/Mammal
  Reason: image not found

I've read Apple's "Run-Path Dependent Libraries" documentation, and Mike Ash's blog post on @rpath, but I still can't see what I'm doing wrong.

Regexident
  • 29,441
  • 10
  • 93
  • 100
JWWalker
  • 22,385
  • 6
  • 55
  • 76

1 Answers1

9

It turns out that the right runpath search path is @loader_path/Frameworks. What I was missing is that @loader_path represents, not the full path to the loader, but that path minus its last component. Mike Ash's blog post does say that, but I somehow missed it. Thus, in the case of a framework, @loader_path ends with the A.

JWWalker
  • 22,385
  • 6
  • 55
  • 76
  • Yes, to be clear: the Installation Directory for both your nested dylib and its parent framework should be "@rpath". The parent framework then includes "@loader_path/Frameworks" in its Runpath Search Paths (since the dylib ends up as a sibling of the Frameworks folder); the app using this framework includes "@loader_path/../Frameworks" (since the executable is down in MacOS). The app could use `@executable_path` just as well, but `@loader_path` seems cooler :-) – natevw Mar 27 '13 at 20:55
  • 2
    I don't understand what you actually did to make it work... explain it to me like I'm 6. – Prof. Falken Oct 23 '14 at 15:37
  • 3
    @Prof.Falken: In the build settings for the framework, under Linking, there is a setting called "Runpath Search Paths". I set its value to `@loader_path/Frameworks`. – JWWalker Oct 24 '14 at 01:34