title: Deploying Qt Frameworks with Mac app and usage of otool
body: <p>I have a problem deploying Qt frameworks with my Mac app, and I hope some will have a clue why I get this error, when I run the app on clean Mac, i.e. not a developer Mac.</p>
  
  <p>OS: 10.7 .2 and using XCode</p>
  
  <p><strong>Error msg:</strong></p>
  
  <pre><code>Library not loaded: @loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
  Referenced from:/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
  </code></pre>
  
  <p>Clearly something is wrong since the QtXml is referenced from /../Frameworks/../Frameworks, which doesn’t exists.</p>
  
  <p>This is the set up: I have a dylib that uses QtCore and QtXml (not by my choosing, but for now I need those two frameworks), the dylib is used in a NSBundle, which is loaded by the main app, the bundle is located in the resource folder. The dylib is moved by Copy Files Build Phase to the folder Contents/Frameworks and with otool the install_name is set to (as stated by <a href="http://doc.qt.digia.com/4.3/deployment-mac.html" rel="nofollow">http://doc.qt.digia.com/4.3/deployment-mac.html</a>):</p>
  
  <pre><code>@loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
  @loader_path/../Frameworks/QtXml.framework/Versions/4/QtXml
  </code></pre>
  
  <p>then the Qt frameworks are moved to Contents/Frameworks  and the install_name of the is set to:</p>
  
  <pre><code>@executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
  </code></pre>
  
  <p>and for the QtXml
      @executable_path/../Frameworks/QtXml.framework/Versions/4/QtXml
  with reference to QtCore:
      @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore</p>
  
  <p>Now when I run the app on the developer mac it clearly works since Qt is installed, but when moved to a clean mac I get the error msg, readable in the Console app.
  I’ve tried to change the executable_path to loader_path, but this didn’t work. 
  I have no idea what I’m doing wrong or why it won't for, and have not been able to find anything on Google, of course I could be looking at the wrong places. Any ideas how to fix this problem?</p>
  
  <p><strong>This is the entire error message:</strong></p>
  
  <blockquote>
    <p>MainApp: Error Domain=NSCocoaErrorDomain Code=3587 "The bundle
    “Library” couldn’t be     loaded because it is damaged or missing
    necessary resources."<br>
    (dlopen_preflight(/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/
    Contents/MacOS/Library): Library not loaded:<br>
    @loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
    Referenced from: /Users/ someUser /Downloads/
    MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
    Reason: image not found) UserInfo=0x107c5d5d0
    {NSLocalizedFailureReason=The bundle is damaged or missing necessary
    resources., NSLocalizedRecoverySuggestion=Try reinstalling the
    bundle.,
    NSFilePath=/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/Library,
    NSDebugDescription=dlopen_preflight(/Users/someUser
    /Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/Library):
    Library not loaded:
    @loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore<br>
    Referenced from:
    /Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
    Reason: image not found,
    NSBundlePath=/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle,
    NSLocalizedDescription=The bundle “Library” couldn’t be loaded because
    it is damaged or missing necessary resources.}</p>
  </blockquote>