dyld: Library not loaded

I am facing an issue where I am trying to launch my application that includes a third party's dylib. Every time I launch I get the following error on the xcode console:

dyld[8660]: Library not loaded: '[thirdparty].dylib'
  Referenced from: '/Path/To/Bundle.app/Contents/MacOS/Bundle'
 '/usr/lib/system/introspection/[thirdparty].dylib' (no such file), '[thirdparty].dylib' (no such file), '/usr/local/lib/[thirdparty].dylib' (no such file), '/usr/lib/[thirdparty].dylib' (no such file), '/usr/lib/system/introspection/[thirdparty].dylib' (no such file), '//[thirdparty].dylib' (no such file), '/usr/local/lib/[thirdparty].dylib' (no such file), '/usr/lib/[thirdparty].dylib' (no such file)

I can confirm that the [thirdparty].dylib file is in the Bundle.app/Contents/Frameworks/ folder.

I tried to see what happens if I put the [thirdparty].dylib file in /usr/local/lib. The dylib can load but I get the following when I launch:

dyld[8743]: Library not loaded: '[thirdparty].dylib'
  Referenced from: '/Path/To/Bundle.app/Contents/MacOS/Bundle'
  Reason: tried: '/usr/lib/system/introspection/[thirdparty].dylib' (no such file), '[thirdparty].dylib' (no such file), '/usr/local/lib/[thirdparty].dylib' (code signature in <15232DEE-7E9E-3788-9D5D-5C677821DD10> '/usr/local/lib/[thirdparty].dylib' not valid for use in process: library load disallowed by system policy), '/usr/lib/[thirdparty].dylib' (no such file),  '/usr/lib/system/introspection/[thirdparty].dylib' (no such file), '//[thirdparty].dylib' (no such file), '/usr/local/lib/[thirdparty].dylib' (code signature in <15232DEE-7E9E-3788-9D5D-5C677821DD10> '/usr/local/lib/[thirdparty].dylib' not valid for use in process: library load disallowed by system policy), '/usr/lib/[thirdparty].dylib' (no such file)

Is not valid for use in process: library load disallowed by system policy a clue?

Other things I've tried:

  1. Ensure that the dylib files were not symbolic links to see if it was a de-referencing issue
  2. Manually resigning
  3. Made sure the dylib is "Embeded & Signed" under General>Frameworks, Libraries, and Embedded Content
  4. Upgrading from Xcode 13.4 to 14.2. Issue still occurs.

Accepted Reply

When it comes to building, embedding, and linking with dynamic libraries, I encourage folks to stay on the happy path that is rpath-relative library references. See Embedding nonstandard code structures in a bundle. Once you’re on that path you can embed your libraries in the Frameworks directory, per the advice in Placing Content in a Bundle. And once you do that, Xcode’s built-in code signing infrastructure tends to work well.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Using the otool to manually insert @rpath into the references worked

Add a Comment

Replies

When it comes to building, embedding, and linking with dynamic libraries, I encourage folks to stay on the happy path that is rpath-relative library references. See Embedding nonstandard code structures in a bundle. Once you’re on that path you can embed your libraries in the Frameworks directory, per the advice in Placing Content in a Bundle. And once you do that, Xcode’s built-in code signing infrastructure tends to work well.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Using the otool to manually insert @rpath into the references worked

Add a Comment