How to Deploy Your Qt Cross-Platform Applications to macOS Operating System Using macdeployqt
This tutorial explains the manner to deploy cross-platform projects made with the Qt framework to macOS Operating Systems using macdeployqt.
Set up the environment
- operating system information (macOS)
- a set-up of Qt Creator IDE ( for macOS)
If you do not have it already, Qt Creator IDE can be downloaded and installed from :
- Qt code from an application
If you wish to get conversant with the Qt cross-platform framework, I recommend following along the courses on Udemy from the following authors:
Daniel Gakwaya | Software Engineer at Blikoon Technologies| Udemy
Daniel is a Senior Software Engineer at Blikoon Technologies. He has been writing software since 2011 and Qt is one of…
Bryan Cairns | Computer Guru| Udemy
"Bryan has a few courses available on Udmey, specifically his course on Qt 5 Design Patterns and also has a popular…
Go deploy the Qt cross-platform application using macdeployqt
macOS uses the concept of bundling. A macOS application is actually a folder that holds a .app extension.
Step 1. Add the “app_bundle” specification in the project’s .pro file
QMake should generate automatically a bundle for the application in the build folder. Nevertheless, it is recommended to add explicitly this in the .pro file:
Step 2. Clean the project from the previous builds
Cleaning the project from previous builds is a good practice to avoid errors that might be related to other builds you have already done.
Step 3. Build the project using the “Release” option
Step 4. Deploy the application for usage in MacOS
4.1. Locate the ‘macdeployqt’ binary inside your Qt installation
4.2. Note the path to the ‘macdeployqt’ :
4.3. Go to the build directory
This directory is generated after building the Qt code (you did this at Step 3)
Same thing, but using the command line:
4.4. Execute ‘macdeployqt’ against the application in the build directory
If you wish to include a custom library in the application bundle, then copy the library into the bundle manually, after the bundle is created.
In order to place the bundle into a disk image for easy distribution, just add the ‘-dmg’ parameter to the command.
macdeployqt also supports these options:
0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug
Skip plugin deployment
Create a .dmg disk image
Don’t run ‘strip’ on the binaries
Deploy imports used by .qml files in the given path
Test and run the application
Verify the contents of the bundle .app
Test run the disk image .dmg
You can also deploy Qt cross-platform applications to macOS using the Qt Installer Framework.
The steps are similar to the ones I already described in the old articles concerning the deployment on Windows or Linux Operating Systems using the Qt Installer Framework. The sole difference is that, in this case of deploying apps for the macOS, you will be using macdeployqt instead of windeployqt or linuxdeployqt.
How to Deploy Your Qt Cross-Platform Applications to Windows Operating System With the Qt…
This tutorial explains how to deploy cross-platform projects made with Qt on Windows using the Qt Installer Framework.
How to Deploy Your Qt Cross-Platform Applications to Linux Operating System With linuxdeployqt
This tutorial explains how we can deploy the projects you worked on with the Qt framework ( Qt Core, Qt Widgets, and Qt…
Read more …
Visit the Qt documentation for the complete reference about the deployment of Qt cross-platform applications to macOS.