People‎ > ‎John Stavrakakis‎ > ‎John's blog‎ > ‎

Xcode: how to link dylib library files

posted 16 Oct 2011, 19:00 by John Stavrakakis
When linking with external dylib for an Xcode project. You might get this error:
dyld: Library not loaded: libXXX.dylib
  Referenced from: .../Developer/Xcode/DerivedData/quack-gpfxwhnflltwzkdnerqlydkddvbj/Build/Products/Debug/zzz
  Reason: image not found

Xcode 4.0 solution
1) click on the project in the side pane to bring up the properties.
2) click on "Target"

Checking the library:
3) In "Build Settings"
4) Using search, enter "library". There should be a path automatically set in the field for "Library Search Paths" if you added the dylib to your project.

Add a copy files phase:
3) In "Build Phases"  
4) Click "Add Build Phases"
5) Click "Add Copy Files"
6) In "Destination" select "Executables"
7) Add entry by clicking the "+"
8) Choose the .dylib file from your project or manually locate it.