Hi. I am writing a GUI app that runs a command line program within its bundle. The program that I am running has @rpath set to @executable/../Frameworks. If I use the terminal and try to run the executable from within Contents/MacOS/, it works fine because the .dylibs it uses are in Contents/Frameworks. The libraries can be reached because they are set to @executable_path/../Frameworks/ using install_name_tool. They are codesigned on copy into Contents/Frameworks in the bundle. Finally I have a script that uses install_name_tool to add-rpath to the executable. However, when I attempt to launch via NSTask, I get the following sent to stderr:
Referenced from: /Users/brant/Library/Developer/Xcode/DerivedData/mh-llrtpd-hjvpryktibfhdaezfcvushvxgovd/Build/Products/Debug/MIXhalo.app/Contents/MacOS/mh-client
Reason: tried: '/Users/brant/Library/Developer/Xcode/DerivedData/mh-llrtpd-hjvpryktibfhdaezfcvushvxgovd/Build/Products/Debug/libjson-c.5.dylib' (no such file), '/usr/lib/system/introspection/libjson-c.5.dylib' (no such file), '@executable/../Frameworks/libjson-c.5.dylib' (no such file), '@executable/../Frameworks/libjson-c.5.dylib' (no such file), '/usr/local/lib/libjson-c.5.dylib' (file system sandbox blocked open()), '/usr/lib/libjson-c.5.dylib' (no such file)
What is different about launching with NSTask that I need to change so that the dynamic linker will work?
It turns out, I needed to add @executable_path/../Frameworks to the "runtime search paths" in the executable I'm trying to invoke with NSTask.