Last time when I was deploying a Qt application on MacOS X I spent several hours struggling with otool and install_name_tool to make my app see all the bundled Qt frameworks and plugins. Then I found out that there is a dedicated tool for it, called macdeployqt and, what is more, it’s nothing new. To be honest, it’s so well known that it is currently shipped together with Qt. Shame on me.

Great then, macdeployqt reduces the deployment work to one line in terminal, and time thereof to several seconds :) However, my application, apart from Qt frameworks uses other custom, self-made frameworks that depend on Qt. It seems that macdeployqt doesn’t support deploying frameworks, as it searches for application binary located in <bundle_name>/Contents/MacOS, which simply doesn’t exist in a framework bundle. So I created a simple script, called frameworkdeployqt.pl that does the dirty work of deploying frameworks written in Qt. The basic concept is:

  1. you want to deploy a Qt application on MacOS X,
  2. your application uses custom/self-made/third-party frameworks written in Qt,
  3. all the frameworks are going to be located in <bundle_name>/Contents/Frameworks.

Then you deploy the application in two simple steps:

  1. run macdeployqt to copy needed Qt frameworks to the application bundle and adjust its internal framework references,
  2. run frameworkdeployqt.pl to make your custom frameworks use Qt frameworks bundled with your application. You’ll of course need perl, but it comes out of the box with MacOS X.

The script looks for non-Qt frameworks inside the bundle given as an argument (namely, it searches <bundle_name>/Contents/Frameworks for frameworks other than Qt*) and then replaces their references to Qt frameworks so that they point to the ones that macdeployqt have just copied to the bundle. For now it’s a bit dumb, i.e. it doesn’t check the existence of Qt frameworks, so if your custom framework uses other Qt modules than the application (or macdeployqt somehow failed to copy them), you’ll have to copy them manually to the bundle.

Other drawback is that you can’t create a dmg image directly using macdeployqt, but anyway, if you happen to need frameworkdeployqt.pl, that dmg would have been useless for you.

The script is available from GitHub. Enjoy!

15 Responses to “Deploying Qt-based frameworks made simple”

comments feed Subscribe to comments
  1. Robert Lipe Says:

    Version 4.5 does support the -dmg flag which creates a .dmg from your .app. It seems to not package the translations, but it does automate a bunch of icky stuff.

  2. ayoy Says:

    Yep, actually what macdeployqt does also is it packages frameworks installed in system to your bundle. But when you have a project that compiles a framework and an application that uses this framework (without installing it), macdeployqt won’t figure out this one. And that’s the situation that my script is meant to handle :)

  3. Events in Pittsburgh Says:

    Thanks for the feedback, actually there’s no mailing list yet (and I don’t have your e-mail :) ), but you can track this blog, I’ll be posting updates here.

  4. Go ped Says:

    Version 4.5 does support the -dmg flag which creates a .dmg from your .app. It seems to not package the translations, but it does automate a bunch of icky stuff.

  5. temp tattoos Says:

    I certainly enjoyed the way you explore your experience and knowledge of the subject!

  6. öar i thailand Says:

    This is a great post! Ive always had problems with these kinds of frameworks. More things like this pls!

  7. speltips Says:

    Thanks, now I understand it a bit better.

  8. teknikblogg Says:

    Great. Thanks for this post. Makes it alot easier.

  9. acne no more scam Says:

    Yes, in fact, even frames macdeployqt packs installed in the system package. But when you have a project that brings together the framework and applications using the framework (without installing), macdeployqt can not find it. And the situation is that my script is designed to handle:)

  10. bilverkstad växjö Says:

    Thank you for sharing this information about Qt basked framworks with us. Post more of this kind and ill be back.

  11. plinaron Says:

    Your site is good Actually, i have seen your post and That was very informative and very entertaining for me. Thanks for posting Really Such Things. I should recommend your site to my friends.buy triactol

  12. krishna Says:

    Hello,

    I am working on qt-creator plugins. There is a option in qt to create app-bundle. If we use CONFIG += app_bundle then it will create bundle for your application. I found that it is not creating plugins folder in side app_bundle. Do we need to specify what are the dynamic libs the application is depend on.

    1. Is there any qmake option for that? 2. If there is no qmake option for that then does macdeplyqt will help me by copying necessary dynamic libs in my app bundle for example myapp.app/Contents/Plugins directory.

    When i run otoool -L myapp then it is providing the list of libraries it is depending on.

    So will macdeployqt will help me by copying necessary libraries automatically in myapp.app/Contents/Plugins folder?

    Please suggest me.

    Br, Krishna

  13. latest news today Says:

    Great post. Very very interesting. My eyes were glued to the screen from the beginning to the end. Loved the first and the last topic. Thanks for sharing the information with us.

  14. tv guide listings Says:

    again very good information! thanks alot!

  15. gift baskets Says:

    I tried that tools too, but unfortunately it didn’t work with me.

Leave a Reply