How to command line build a proper dmg from a Qt app
-
I have Qt app lets say
MyAppwith a list of libraries it links to. Note that all libraries are linked statically linked. I have a master project file calledMyMasterProjectFile.prowhich loads all of these into QtCreator and yes the whole code builds well from QtCreator. I am using Qt 5.9.4 commercial version.I want to build my app+libraries command line into a
dmgforMacOS High Sierra. I am doing this support CI builds on my build system.So, following is what my script does:
// MyBuildScript.sh BuildDMGForMacOS() { /path/to/qmake MyMasterProjectFile.pro -spec macx-clang CONFIG+=Release CONFIG+=x86_64 $EXTRA_SETTINGS CONFIG+=qml_debug make -j2 // Go inside the directory where my main app build folder is created /path/to/macdeployqt MyApp.app -verbose=2 -dmg }Issue:
The dmg that is generated is not correct. But this is because if I double click and try to run the .app that is generated, I get the following errorYou can’t open the application “MyApp.app” because it is not
supported on this type of Mac.Question:
Looking at my script above, what am I missing in the methodBuildDMGForMacOSto build a dmg for OSX?Note:
Note that the dmg will be installed on OSX machines which wont have Qt installed on them. -
Hi,
macdeployqtuses system tools to build the .dmg. These tools depending on the macOS version you have as well as your root file system will not generate the same .dmg content. There's now an option in the more recent versions ofmacdeployqtthat allows to set the filesystem used to build the .dmg and uses a sensible default that is backward compatible. -
Hi,
macdeployqtuses system tools to build the .dmg. These tools depending on the macOS version you have as well as your root file system will not generate the same .dmg content. There's now an option in the more recent versions ofmacdeployqtthat allows to set the filesystem used to build the .dmg and uses a sensible default that is backward compatible.@SGaist Is there an example I can get on how to use the new way in
macdeployqtto get a properdmg? -
Just use a recent version of
macdeployqt. The option is-fs. -
Looks like
-fsdid somthing with filestystem. I can see it logged the follwing extra thing. But its still the same issueLog: Image will use "HFS+"But, If I open
MyApp/MyApp.app/Contents/MacOS/MyAppthen it complains the following on console and gives up with a crashQQmlApplicationEngine failed to load component qrc:/qml/main.qml:1 module "QtQuick" is not installed qrc:/qml/main.qml:4 module "QtWebView" is not installed qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed qrc:/qml/main.qml:1 module "QtQuick" is not installed qrc:/qml/main.qml:4 module "QtWebView" is not installed qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed qrc:/qml/main.qml:1 module "QtQuick" is not installed qrc:/qml/main.qml:4 module "QtWebView" is not installed qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed qrc:/qml/main.qml:1 module "QtQuick" is not installed qrc:/qml/main.qml:4 module "QtWebView" is not installed qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed [1] 57951 segmentation fault /Volumes/MyApp/MyApp.app/Contents/MacOS/MyApp -
You did not use the
qmldiroption when running macdeployqt. -
@SGaist
Ah superb ! This made a difference. Now if I doubled clicked on the dmg and openedMyApp/MyApp.app/Contents/MacOS/MyAppthat is inside it. It works and I am able to launch my app.Thanks a lot till here.
But I am still curious why just double clicking on
MyAppdies not work? Why do I have to runMyApp/MyApp.app/Contents/MacOS/MyAppinstead of justMyApp? -
Do you have any error message ?
-
@SGaist
The error message says following with a pop upYou can’t open the application “MyApp.app” because it is not
supported on this type of Mac. -
Are you using a pre-built version of Qt to build your application ?
By the way, why not use a more recent version of 5.9 ?
-
Are you using a pre-built version of Qt to build your application ?
By the way, why not use a more recent version of 5.9 ?
Do you mean 5.9.6 ? I am using 5.9.4 but this error occurs even if I build with
5.11.2. -
Can you show your .pro file ?
-
My .pro file has so many things which is due to multiple stuff and it would not make much sense to share it here. But I have set
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12andQML_IMPORT_PATHis set to nothing. Plus, following are some more settings I have in my .pro which might be relevant to this questionCONFIG += c++14 CONFIG -= bitcodeI am marking this Topic as solved. Do let me know if have a suggestion on this last error.