MacRuby release app missing libmacruby.dylib - xcode

Using XCode 4.5.2 and MacRuby 0.12, my app works fine on my computer but the release version won't work on others computers :
Dyld Error Message:
Library not loaded: /Library/Frameworks/MacRuby.framework/Versions/0.12/usr/lib/libmacruby.dylib
Referenced from: /Users/USER/Desktop/PocheFactory.app/Contents/MacOS/PocheFactory
Reason: image not found
I have checked my deployment settings and they seems fine:
In the BuildPhases->"Link Binary With Libraries", I have the "MacRuby.framework" required and in the BuildSettings->Framework Search Paths, I have include "/Library/Frameworks" with recursive option.
How come this particular library is not included within the release version?
Any idea?

Rather than figuring out the right Xcode settings, it's much easier to run this:
/usr/local/bin/macruby_deploy --compile --embed
I got this info from Matt Aimonetti's MacRuby, The Definitive Guide.
(The last command argument was stripped off: it's the path to the application bundle in Derived Data that was created by Xcode.)

Related

OSX App crashing on load when ParseOSX framework with Dyld Error

I have an OSX app and I have added the ParseOSX sdk. I have followed all the instructions on the quick start page (https://www.parse.com/apps/quickstart#parse_data/desktop/osx/existing)
The app is running fine in Xcode (Version 5.1.1 (5B1008)) but when I archive and create a package and install this. I get the following Dyld error;
Dyld Error Message:
Library not loaded: #executable_path/../Frameworks/ParseOSX.framework/ParseOSX
Referenced from: /Applications/MyApp.app/Contents/MacOS/MyApp
Reason: image not found
It goes on and lists the Binary Images loaded.
Searching the web I found reference to adding a copy files build phase and adding the parse framework to that with the destination set to Products directory.
So it appears there is a dynamic lib not being installed somewhere.
UPDATE:
I just cleaned the build folder and now the app will not even run under Xcode. I get:
dyld: Library not loaded: #executable_path/../Frameworks/ParseOSX.framework/ParseOSX
Referenced from: /Users/Ants/Library/Developer/Xcode/DerivedData/MyApp-hjrbgyhzpwnxhiaskxpojqyqxnvh/Build/Products/Debug/Actual.app/Contents/MacOS/MyApp
Reason: image not found
UPDATE 2:
It turns out when you are in the quick start page. If you chose the new app option you get a Xcode project. This compiles. Going through it I can see that there is is a Copy Files step that copies the ParseOSX.framework into the Frameworks destination. Tried this is my app and I now get a signing error
/Users/Ants/Library/Developer/Xcode/DerivedData/MyApp-hjrbgyhzpwnxhiaskxpojqyqxnvh/Build/Products/Debug/MyApp.app: code object is not signed at all
In subcomponent: /Users/Ants/Library/Developer/Xcode/DerivedData/MyApp-hjrbgyhzpwnxhiaskxpojqyqxnvh/Build/Products/Debug/MyApp.app/Contents/Frameworks/ParseOSX.framework
I ran into the same problem with xcode 6.1. Fixed it by adding ParseOSX.framework to "Embedded Binaries" on the general tab of the Targets page.
Two things fixed this for me.
First I needed to add a copy files section to the build phases and copy the ParseOSX.framework into the Frameworks destination.
And second, I needed to add --deep to the "Other Code Signing Flags" in the Code Signing section of Build Settings. It now signs the frameworks being copied it seems.
I was updating an existing parse project to the newest SDK (1.12.0) using Xcode 7.2 and ran into the same problem.
The solution for me was to set Runpath Search Paths to #executable_path/../Frameworks.
I found this by comparing the Starter project from Parse to my project.

Xcode can run my program, but I can't run it manually

I have a project with a dynamic library and an executable that links against it. I can successfully start it with Xcode, but when I try to run it from the command line, dyld complains about the library not being in the install path:
$ /Users/USER/Library/Developer/Xcode/DerivedData/PROJECT/Build/Products/Debug/EXECUTABLE
dyld: Library not loaded: /usr/local/lib/libMyLib.dylib
Referenced from: /Users/USER/Library/Developer/Xcode/DerivedData/PROJECT/Build/Products/Debug/EXECUTABLE
Reason: image not found
Trace/BPT trap: 5
The problem is quite clear: the library isn't in its advertised install path. However, I don't really want to deploy it there, and besides, Xcode still manages to start my program.
How can I run my program without installing the library in /usr/local/lib?
If you're relying on a dylib, then it needs to be installed in the appropriate location.
Using a framework might help, as you can package it in your application, using #executable_path...
But then, of course, you won't be able to share it across different applications.
So basically, you need to tell Xcode to install your dynamic library.
This can be done in your build settings, in the Deployment section.
Mainly, Deployment location, Installation directory, Skip install, etc...
Note that you can also do this for frameworks, installing them into /Library/Frameworks/

dyld: Library not loaded ... Reason: Image not found

When trying to run an executable I've been sent in Mac OS X, I get the following error
dyld: Library not loaded: libboost_atomic.dylib
Referenced from: /Users/"Directory my executable is in"
Reason: image not found
Trace/BPT trap:5
I have installed the boost libraries and they are located in /opt/local/lib. I think the problem has something to do with the executable only looking in the directory it is in as when I paste the 'libboost_atomic.dylib' in there, it doesn't mind about it anymore. Unfortunately then it complains it can't find the next boost library.
Is there an easy way to fix this?
Find all the boost libraries (where exefile is the name of your executable):
$ otool -L exefile
exefile:
#executable_path/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
and for each libboost_xxx.dylib, do:
$ install_name_tool -change #executable_path/libboost_something.dylib /opt/local/lib/libboost_something.dylib exefile
and finally verify using otool again:
$ otool -L exefile
exefile:
/opt/local/lib/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
Manpages: otool install_name_tool
EDIT A while back I wrote a python script (copy_dylibs.py) to work out all this stuff automatically when building an app. It will package up all libraries from /usr/local or /opt/local into the app bundle and fix references to those libraries to use #rpath. This means you can easily install third-party library using Homebrew and package them just as easily.
I have now made this script public on github.
This worked for me:
brew upgrade node
In the target's General tab, there is a section called Frameworks, Libraries, and Embedded Content
Click on the + sign, add required framework and the crash is resolved.
After upgrade Mac OS to Mojave. I tried to install npm modules via yarn command I got error:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Abort trap: 6
Was fixed with:
brew update
brew upgrade
For some, this could be as easy as setting the system path for dynamic libraries. On OS X, this is as simple as setting the DYLD_LIBRARY_PATH environment variable. See:
Is it OK to use DYLD_LIBRARY_PATH on Mac OS X? And, what's the dynamic library search algorithm with it?
this should fix the issue
brew update
brew upgrade
brew cleanup
I got this error when I tried to install ruby 2.3.1 using rvm. It first told me to run brew update, which I did, and then when I tried running rvm install ruby-2.3.1, I received the error in this SO question.
The fix was to first run brew upgrade, apparently according to this superuser.com question you need to do both brew update && brew upgrade. Once that was done, I could finally install ruby 2.3.1.
Now that Xcode has upgraded their IDE, they have changed a little bit how this functions.
It used to be split up into separate section as demonstrated above with 'Embedded Binaries' and 'Linked Frameworks and Libraries' as separate sections.
Now, it is one combined section with drop-downs on the right as to what should be embedded.
This was confusing to me at first, but makes perfect sense now.
If you're using Xcode 11 onwards:
Go to General tab and add the framework in Frameworks, Libraries, and Embedded Content section.
Important: By default it might be marked as Do Not Embed, change it to Embed Without Signing like shown in the image and you are good to go.
For Xcode versions below 11:
Just add the framework in Embedded Binaries section and you are done.
Cheers!
To resolve the error below on my Macbook Catalina 10.15.4:
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/bin/mongoexport
Reason: image not found
Abort trap: 6
I ran the command below and got round the problem above:
brew switch openssl 1.0.2s
You can use the otool command with the -L option for the executable, which will display where the executable is expecting those libraries to be.
If the path to those need changing, use the install_name_tool command, which allows you to set the path to the libraries.
Making the Frameworks in the Build Phases Optional worked for me.
In Xcode -> Target -> Build Phases -> Link Binary with Libraries ->
Make sure the newly added frameworks if any are marked as Optional
I got here trying to run a program I just compiled using CMake. When I try to run it, it complains saying:
dyld: Library not loaded: libboost_system.dylib
Referenced from: /Users/path/to/my/executable
Reason: image not found
I circumvented the problem telling CMake to use the static version of Boost, instead of letting it use the dynamic one:
set(Boost_USE_STATIC_LIBS ON)
I fix it by brew install libpng
If you use cmake, add DYLIB_INSTALL_NAME_BASE "#rpath" to target properties:
set_target_properties(target_dyLib PROPERTIES
# # for FRAMEWORK begin
# FRAMEWORK TRUE
# FRAMEWORK_VERSION C
# MACOSX_FRAMEWORK_IDENTIFIER com.cmake.targetname
# MACOSX_FRAMEWORK_INFO_PLIST ./Info.plist
# PUBLIC_HEADER targetname.h
# # for FRAMEWORK end
IPHONEOS_DEPLOYMENT_TARGET "8.0"
DYLIB_INSTALL_NAME_BASE "#rpath" # this is the key point
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
DEVELOPMENT_TEAM "${DEVELOPMENT_TEAM}"
)
or in Xcode dynamic library project Target -> Build Setting set Dynamic Library Install Name Base to #rpath
I fixed this issue by using Product > Clean Build Folder (CommandShiftK), which makes a new clean build, really odd.
For my framework I was using an Xcode subproject added as a git submodule.
I believe I was getting this error because I was signing the framework with a different signing Team than my main app. (switched teams for app; forgot to switch for framework)
Solution is to not sign within the framework project. Instead, in the main app's Target > General > Frameworks, Libraries, and Embedded Content section, sign the framework via Embed & Sign.
If I select Do not Embed or Embed Without Signing I instead get the error:
FRAMEWORK not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
You can use sudo install_name_tool -change change dylib path
And
sudo install_name_tool -id change dylib name
if you use virtualenv just remove the folder of your environment and recreate it with this command
virtualenv --python=/usr/local/bin/python3 the_name_of_my_env
Xcode 11.1 & Swift 5.1
Quick Fix
First make sure that external added library has option embed is selected in General Tab, Embbed Binaries.
If still not works..
This happens because you have different, unmatched versions of libraries present.
Update the Pods
pod update
Important: Check all libraries are included in the Build Settings -> libraries and frameworks list and you have given option to embbed in the build
Just working awesome
In our case, it's an iOS app, built on Xcode 11.5, using cocoapods (and cocoapods-binary if you will).
We were seeing this crash:
dyld: Library not loaded: #rpath/PINOperation.framework/PINOperation
Referenced from: /private/var/containers/Bundle/Application/4C5F5E4C-8B71-4351-A0AB-C20333544569/Tellus.app/Frameworks/PINRemoteImage.framework/PINRemoteImage
Reason: image not found
Turns out that I had to delete the pods cache and re-run pod install, so Xcode would point this diff:
For anyone coming to this page because they got this error trying to link a third party framework to their project using Xcode 6.3.1, the problem I ran into was because the library was being created with an older version of the compiler using a different version of swift. The only way to fix this for me was to re-build the framework.
Another reason you might get this is stated in an Apple technical doc..
If you are building an app that does not use Swift but embeds content such as a framework that does, Xcode will not include these libraries in your app. As a result, your app will crash upon launching with an error message looking as follows:
set the Embedded Content Contains Swift Code (EMBEDDED_CONTENT_CONTAINS_SWIFT) build setting to YES in your app
Here is the link to the full Apple doc that explains it here
For anyone experiencing the same thing with a different library or package, #user3835452 is on the right track. I found this message while trying to run composer:
dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
Referenced from: /usr/local/opt/php#7.1/bin/php
Reason: image not found
Abort trap: 6
After trying a lot of different ways I just ran brew install openldap and it fixed it. Note that I had already ran brew update and brew upgrade but only after I manually installed openldap did it actually work.
Is there an easy way to fix this?
I just used brew upgrade <the tool>. In my case, brew upgrade tmux.
In my case it was node that was out of date, you need to upgrade it after goin up to BigSur - brew upgrade node
As said in https://gist.github.com/berkedel/d1fc6d13651c16002f64653096d1fded, you could try
brew uninstall --ignore-dependencies node icu4c
brew install node
brew link --overwrite node
Quick Fix
Remove the pod (whose name is in the error) by commenting it in your Podfile, like #Podname
Run pod install
Uncomment the pod that you commented earlier
Run pod install again.
It worked for me and is easy to do so sharing it.
I faced the app crash issue quoting SIGABRT error in thread.Overview of the crash is dyld library not loaded and image not found something like that.
This was seen in Xcode 9.3. The reason I found out was Xcode is not picking up libraries dynamically so I had to do it manually which solved my crash issue.
Follow the below steps:
Go to Build Phases
Hit the '+' button at the top and select "New Copy File Phase"
Select Destination as Frameworks and Hit the '+' button below to add files.
Select Add Other at below, click CMD+SHIFT+G and paste the below path,
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
Now you will be able to see some swift dylibs, Select all the swift libraries with .dylib extension and click on open.
These will get added to the embedded binaries in the general tab of app.
Create a new group in project folder and add all these libraries.
Now run your app.
If you are using Conda environment in the terminal, update the samtools to solve it.
conda install -c bioconda samtools
Best one is answered above first check what is the output of
otool -L
And then do the following if incorrect
set_target_properties(
MyTarget
PROPERTIES
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS
"#executable_path/Frameworks #loader_path/Frameworks"
)
And
set_target_properties(
MyTarget
PROPERTIES
XCODE_ATTRIBUTE_DYLIB_INSTALL_NAME_BASE
"#rpath"

Xcode 4.5 no such file or directory - libCordova.a

clang: error: no such file or directory: '/Users/admin/Library/Developer/Xcode/DerivedData/__TESTING__-fzbkvdbnndieeagphtjhdndiyttl/Build/Products/Debug-iphoneos/libCordova.a'
How do I get this a missing libCordova.a ?
(source: kerrydeaf.com)
UPDATE: For Simon Germain.
UPDATE: For Simon Germain. I don't see "Identity and Type". I can see "Identity". I'm using xcode 4.5
(source: kerrydeaf.com)
UPDATE: For Simon Germain. I got the Identity.
(source: kerrydeaf.com)
UPDATE: For Samuel
(source: kerrydeaf.com)
UPDATE: For Simon Germain - Architecture.
UPDATE: For james0n - armv.
(source: kerrydeaf.com)
UPDATE: For Simon Germain - Architecture.
UPDATE: For james0n - armv.
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CDVURLProtocol", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_CDVViewController", referenced from:
_OBJC_CLASS_$_MainViewController in MainViewController.o
"_OBJC_METACLASS_$_CDVViewController", referenced from:
_OBJC_METACLASS_$_MainViewController in MainViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
UPDATE: For james0n - Valid Architecture.
(source: kerrydeaf.com)
UPDATE: It is now solved!!! make sure all armv7 and armv7s for ios 6 on all in xcode. It worked.
For your project, set the build setting "Build Active Architecture Only" to yes.
(Maybe also set the the Architectures build setting to "Standard (armv7, armv7s)" for CordovaLib project.)
Had (as many others) the same problem, here's what I did:
Redid the Getting Started guide from Phonegap (including downloading
and extracting the source again)
Same problem with the HelloWorld app
product - clean
Changed both the 'HelloWorld' and 'CordovaLib'-project (so not the Targets) according to james0n's answer, settings:
Architectures: Standard (armv7, armv7s)
Build Active Architecture only: Yes
and then it magically worked, I think steps 3 and 4 did it however.
Only need to remove armv6 from both YourProject and CordovaLib:
The consequences of doing this? Apparently, it's still working on iPhone 3GS, but not the previous versions..
I had the same problem as you, worked fine deployed to the simulators but not to a device. Neither of the suggested answers worked for me.
Here's what did work for me:
Set deployment target to v4.3 and on the project settings for the CordovaLib project, set the Build Active Architecture Only to Yes. (Not needed on your main project).
Important, do a Product-> Clean and rebuild.
Make sure that the CordovaLib's product's target is set to "Relative to Built Product" on the right hand-side panel, first tab on theleft, under "Identity and Type".
Download the Cordova installer from here http://phonegap.com/download. Make sure it is the same version that you are currently using (ex 2.0).
Then mount the dmg found in the ios directory.
Then run the .pkg installer.
Restart Xcode.
You gotta run the update script, I know it might be a pain in the butt to do it, but that's what it takes.
Download and open the Phonegap 2.1 package from the official site. Open a terminal window, and cd to the installation directory
You'll need to first create a new project:
./create [project_folder_path] [package_name] [project_name]
Then you need to set the path to your libraries.
/update_cordova_subproject [xcodeproj file]
Now open up your project and set the deployment target to 4.3 and you should be ready to go. Hope that helps
EDIT:
This is how my configuration looks like for CordovaLib Project
Also - make sure you don't have more than one PhoneGap Xcode project open at a time - I was getting conflicts between the two. "Workspace already open in another workspace" type of loop.
After spending many hours with even more errors, here's what worked for me. Basically combining much of the above:
Start with a fresh copy of Cordova. If you've been messing with it like me, it's not fresh anymore.
Move the Cordova files out of the download directory (I tend to clean that directory now and then...)
Create a new project as described in the Phonegap docs, i.e. drag the ios/bin folder to the Terminal icon and run the create script in Terminal. No need to run the update_cordova_subproject script.
Open the project in XCode.
For your product, set the iOS Deployment Target to 4.3 (I did it 2x, both in Project and Target Build Settings).
For CordovaLib.xcodeproj, set Build for Active Architecture to Yes in the Project Build Settings.
Clean and run.
Do not include armv7s in any of the architecture lists, as it will not build for device.
Tested in simulator and on an iPad with iOS 6. Using Phonegap 2.1.0 and XCode 4.5.1.
Update: if you want to support iPhone 5, you will need armv7s. It requires the fix in https://issues.apache.org/jira/browse/CB-1360 , which will be in Cordova 2.2.0. (Haven't tried it yet, working on an iPad project.)
I fixed this by removing the armv6 and i386 architecture from Valid Architecture setting
I had this problem too. I think it was because I had previously installed an old version of phone gap that installed some stuff in xcode. I uninstalled, then reinstalled xcode. Then I ran the Uninstall Cordova.applescript that came with phone gap. This fixed the problem of the red libCordova.a
In addition to several other suggestions & post, I found that I was experiencing this problem on my AdHoc builds only. Please note that I figured this out during debugging because if I set the Edit Scheme > Archive build configuration to "release" it would work OK, but if set to AdHoc it would give me a link error, telling me that this file could not be found:
/Users/jason/Library/Developer/Xcode/DerivedData/MommyNearest-ceourmykvgxdekbkmzenuvhcfnzk/Build/Intermediates/ArchiveIntermediates/MommyNearest/BuildProductsPath/Adhoc-iphoneos/libCordova.a
This was actually a good clue to what the problem was, which was that somehow the CordovaLib subproject did not have an AdHoc configuration (it had ONLY "Debug" and "Release" configurations).
Therefore, when building for an AdHoc release (to use with Testflight) it would not create a symlink for this file correctly. Once I added an "AdHoc" configuration to the CordovaLib subproject, this started working.

Deploying Qt Frameworks with Mac app and usage of otool

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.
OS: 10.7 .2 and using XCode
Error msg:
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
Clearly something is wrong since the QtXml is referenced from /../Frameworks/../Frameworks, which doesn’t exists.
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 http://doc.qt.digia.com/4.3/deployment-mac.html):
#loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
#loader_path/../Frameworks/QtXml.framework/Versions/4/QtXml
then the Qt frameworks are moved to Contents/Frameworks and the install_name of the is set to:
#executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
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
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?
This is the entire error message:
MainApp: Error Domain=NSCocoaErrorDomain Code=3587 "The bundle
“Library” couldn’t be loaded because it is damaged or missing
necessary resources."
(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
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
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.}
On the development mac everything works because the Qt libraries are installed. On any mac you ship the app to, though, this likely won't be the case. The Qt suite comes with a tool called macdeployqt to fix this. So in a terminal, after you've compiled your application, do something like:
# cd my-cool-app-Desktop
# macdeployqt my-cool-app.app
Note that it can also be used to create a .dmg file for shipping everything together:
# cd my-cool-app-Desktop
# macdeployqt my-cool-app.app -dmg
Once you've done that, the .app directory or .dmg file can be given to someone else without Qt installed to use and run as they normally would.
The one caveat is that the next time you try to run it on your developer machine, it may complain about multiple shared libraries installed. So once you've copied it else where in order to distribute it, remove the entire .app directory and let qtcreator (or whatever) rebuild it.
UPDATE
As stated compiling QT to static libs is the way to go. With the release of Mavericks (10.9) we need to codesign frameworks as well (http://furbo.org/2013/10/17/code-signing-and-mavericks/), and with QT4.8.5 there are some issues (https://bugreports.qt-project.org/browse/QTBUG-32896). Even with suggested fixes I still had some issues when running the app on a clean machine. Therefore, I ended up with compiling Qt5.2 to staticlibs, link them in the app, and codesign them.
OLD
Problem sovled, I moved the Qt-frameworks into the app bundle in Contents/Frameworks and with otool set the path to #executable_path/../Frameworks, i.e. moved it out of my library bundle. Yes the solution is simple, but I'm still not sure why the library executable couldn't find the frameworks when using #loader_path.
The best solution would probably be to use a static library and not wrap it in a bundle...you learn everyday ;)

Resources