title: Setting dylib paths as a XCode build step
body: <p>I have a Cocoa application as XCode project that has several supplementary bits of functionality as dylib targets.</p>
  
  <p>When XCode builds the project, it places all the build outputs in a single folder: The .app bundle and the dylib files. And when executed from the XCode debugger, the .app launches.</p>
  
  <p>I can't however launch the application from finder.</p>
  
  <p>How do I setup XCode to 'deploy' the app in a standalone state? I have found that I can use <code>ld</code> on the actual app binary to contain a relative path to the dylibs: <code>@executable_path/../../mylib.dylib</code></p>
  
  <p>Running a script after each build seems wrong: there must be some way (that Im totally missing) to do this easily from inside XCode - it must be a common issue surely?</p>
  
  <hr>
  
  <p>It looks like that XCode supports having @executable_path, @loader_path and @rpath used in the Target Info > Build > Linking > Dynamic Library Install Name setting (LD_DYLIB_INSTALL_NAME) setting.</p>
  
  <p>The help text says: "Sets an internal "install path" (LC_ID_DYLIB) in a dynamic library. Any clients linked against the library will record that path as the way dyld should locate this library"</p>
  
  <p>This seems very promising, but usability is a problem if I need to link dylibs in multiple paths against a common library - the relative path is going to be different each time.</p>
  
  <hr>
  
  <p>Running my testapp from finder, I get the following (relevant) error text</p>
  
  <pre><code>Dyld Error Message:
    Library not loaded: @executable_path/../../util.dylib
    Referenced from: /Volumes/data/Code/TestApp/build/Debug/TestApp.app/Contents/MacOS/TestApp
    Reason: image not found
  </code></pre>
  
  <p>util.dylib is in /Volumes/data/Code/TestApp/build/Debug/ so I am confused :/</p>