[Interest] Deploying Qt to MacOs still...errr, sucks?

Prashanth Udupa prashanth.udupa at gmail.com
Fri Nov 11 09:41:12 CET 2016


Hi Jean,

I am working on a project that involves deployment on Mac. I have a shell
script that packages the app into a DMG file or PKG file. It works for me
quite well. I am able to deploy a Qt 5.7 app to any Mac running Mac OS 10.8
and later.

1. Suppose that you are writing an app called "MyWonderfulApp". After
building the app, there will be a MyWonderfullApp.app/ folder in your
$$DESTDIR.
2. Suppose that you need to bundle a few more command line tools (which
link against Qt libs and maybe external DYLIBs) into your app-bundle.
3. Suppose also that you need to bundle additional DYLIBs.
4. Suppose also that you need to bundle QML components & desktop controls
that are referenced by your app.
5. Suppose that both MyWonderfullApp and the command-line-tool depends on
similar set of Qt frameworks and external libraries.

Below is usable snippets of the shell script. Hopefully they are of some
use to you. It will need more tweaking depending on your specific app and
its dependencies.

---------------
cd $DESTDIR

*# Copy command line tool to the app-bundle*
cp -vaRf cmdLineTool MyWonderfulApp.app/Contents/MacOS

*# Copy external libs to your app-bundle*
mkdir MyWonderfulApp.app/Contents/Frameworks
cp -vaRf /path/to/external/lib/externalLib.dylib
MyWonderfulApp.app/Contents/Frameworks/
install_name_tool -id @executable_path/../Frameworks/externalLib.dylib
MyWonderfulApp.app/Contents/Frameworks/externalLib.dylib

*# Map externalLib.dylib to a path within the app-bundle*
install_name_tool -change /path/to/external/lib/externalLib.dylib
@executable_path/../Frameworks/externalLib.dylib
MyWonderfulApp.app/Contents/MacOS/MyWonderfulApp
install_name_tool -change /path/to/external/lib/externalLib.dylib
@executable_path/../Frameworks/externalLib.dylib
MyWonderfulApp.app/Contents/MacOS/cmdLineTool

*# Map Qt frameworks used by cmdLineTool to the ones within the
app-bundle. *
*# (The frameworks will be copied when you use macdeployqt)*
install_name_tool -change @rpath/QtNetwork.framework/Versions/5/QtNetwork
@executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork
MyWonderfulApp.app/Contents/MacOS/cmdLineTool
install_name_tool -change @rpath/QtCore.framework/Versions/5/QtCore
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore
MyWonderfulApp.app/Contents/MacOS/cmdLineTool
install_name_tool -change @rpath/QtXml.framework/Versions/5/QtXml
@executable_path/../Frameworks/QtXml.framework/Versions/5/QtXml
MyWonderfulApp.app/Contents/MacOS/cmdLineTool

*# Use macdeployqt to bundle everything else (frameworks, QML components,
Qt Desktop controls, plugins etc..)*
$QTDIR/macdeployqt MyWonderfulApp.app -always-overwrite
-qmldir=/path/to/qml_files_in_your_project -verbose=1 -appstore-compliant
-dmg

*# Now use MyWonderfulApp.dmg to distribute*
---------------

If you want to distribute your app as a pkg file, then change the
macdeployqt usage as follows

---------------
$QTDIR/macdeployqt MyWonderfulApp.app -always-overwrite
-qmldir=/path/to/qml_files_in_your_project -verbose=1 -appstore-compliant
productbuild --component MyWonderfulApp.app /Applications MyWonderfulApp.pkg

*# Distribute the MyWonderfulApp.pkg file now.*
---------------

Hope this helps.

Thanks,
Prashanth

On Thu, 10 Nov 2016 at 22:42 Jean-Michaël Celerier <
jeanmichael.celerier at gmail.com> wrote:

> Late bump :
>
> The documentation is still lacking.
> For instance, where should one deploy QtQuick's QML files ?
>
> Upon inspection it seems that some plug-ins are put in
> Contents/PlugIns/quick, some QML files in Resources/qml (similarly to
> what's in Qt/5.$version/$platform/qml folder) and symlinks in
> Resources/qml/QtQuick (or others) to the actual qml plug-ins.
>
> Is all of this necessary ?
>
> Best,
> Jean-Michaël
>

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161111/abf5db96/attachment.html>


More information about the Interest mailing list