[Interest] Deploying Qt to macOS still...errr, sucks?
Jake Petroules
Jake.Petroules at qt.io
Fri Nov 11 10:37:53 CET 2016
> On Nov 11, 2016, at 12:41 AM, Prashanth Udupa <prashanth.udupa at gmail.com> wrote:
>
> 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
Don't do that last install_name_tool command. Instead, build your dynamic library with:
in qmake...
QMAKE_SONAME_PREFIX = @rpath (which is equivalent to QMAKE_LFLAGS += -Wl,-install_name, at rpath/externalLib.dylib)
or in qbs...
cpp.sonamePrefix: "@rpath"
and build your main application and command line helper tool with:
in qmake...
QMAKE_RPATHDIR += @loader_path/../Frameworks (which is equivalent to QMAKE_LFLAGS += -Wl,-rpath, at loader_path/../Frameworks)
or in qbs...
cpp.rpaths: ["@loader_path/../Frameworks"]
>
> # 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
Not needed, given the above.
>
> # 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
Also not needed, given the above.
> # 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
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
--
Jake Petroules - jake.petroules at qt.io
The Qt Company - Silicon Valley
Qbs build tool evangelist - qbs.io
More information about the Interest
mailing list