Shared Library Debugging under El Capitan

In my day job, I do a lot of debugging of apps that use libraries in non-standard locations. This has traditionally been performed by exporting DYLD_LIBRARY_PATH in your environment and then debugging your app as normal.

$ export DYLD_LIBRARY_PATH=/path/to/lib/dir
$ lldb ./myapp
(lldb) r myapp_arg1 myapp_arg2

Under El Capitan, dyld environment variables are purged when spawning processes, thanks to System Integrity Protection. This means that you’ll have to use lldb to set the variable at debug-time.

$ lldb ./myapp
# 'r' and 'run' are aliases to 'process launch -X true --'
(lldb) process launch -v DYLD_LIBRARY_PATH=/path/to/lib/dir -X true -- myapp_arg1 myapp_arg2

If you always use the same shared library path, you might be able to make new aliases in your .lldbinit.