Reputation: 907
In my Xcode project, I have several dynamic libraries that I built with a prefix of "@rpath/lib". I added a "copy files" build phase that includes these dylibs. They are installed to a folder called lib in Frameworks. I also set a Runpath Search path of "@loader_path/../Frameworks" which should be substituted as @rpath when the executable runs. DLYD looks at my binary's runpath which I examine using tool -l command on the binary. This produces:
Load command 47
cmd LC_RPATH
cmdsize 40
path @loader_path/../Frameworks (offset 12)
So I assume that when my binary runs, DLYD will resolve the path the lib folder via the MACH-O binary.
When I run my project, I use Activity Monitor to examine the files the binary has open. I don't see my dynamic libraries being referenced from @loaderpath/../Frameworks/lib where they reside, instead I see them being referenced from /usr/local/lib.
What Xcode settings do I set so my dynamic libraries are properly found? I used the User-Defined build setting 'DYLD_PRINT_BINDINGS' to see what is linking, and I don't see my libraries being linked even though they are eventually linked against the libraries in /usr/local/lib
Upvotes: 1
Views: 844
Reputation: 122458
I have found the script I developed a while back which I used to copy .dylib
s into the .app
's Framework
directory and detect dependent libraries, fixing the library references using install_name_tool
. This should be set as a post-build script.
https://github.com/trojanfoe/xcodedevtools/blob/master/copy_dylibs.py
I haven't tested it for a while. The repo also contains the script I now use to bump build numbers, as per this question of mine.
Upvotes: 1