Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

crystalidea/macdeployqt-universal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Update: the tutorial is outdated

Qt Group open sourced Qt 5.15.9 with macOS universal binaries support.

If you're still interested for some reason, proceed reading.

Deploying macOS universal binaries using Qt 5.15.8

With Apple transition from Intel to Apple Silicon (arm64) CPUs, developers have to deal with Universal binaries in macOS (again) in order to support their apps running smoothly on both architectures. For Qt developers things get much more complicated because we have to take care of signing, notarization and Universal binaries creation without using XCode.

This article explains how we at CrystalIDEA used to deploy macOS versions of our apps (before official support of universal builds in Qt). We hope that it can be useful for other indie developers who are still on Qt 5.15.8 for various reasons (e.g. Windows 7 & macOS 10.13 support).

The build process takes place on Intel machine running macOS 10.15 (Catalina) or 11 (Big Sur), Qt Creator 5/6 and XCode 12/13.

Disclaimer: the described process is unlikely to be optimal, any improvement ideas and comments are welcome.

Prerequisites

  • Qt built for x86_64. It's installed (by default) to /usr/local/Qt-5.15.8
  • Qt built for arm64 using the QMAKE_APPLE_DEVICE_ARCHS=arm64 configure switch and -prefix /usr/local/Qt-5.15.8-arm to install it to /usr/local/Qt-5.15.8-arm
  • Qt Creator should have these two Qt versions added and two corresponding kits for each

  • Our modified version of macdeployqt with support of the -qtdir switch that speficies actual Qt directory. You can compile it yourself or download our precompiled binary (it has no dependencies as Qt is statically linked)
  • makeuniversal tool which merges two folders with x86_64 and arm64 binaries of your app into a universal binary. Here we also provice the precompiled binary with zero dependencies
  • A tool to notarize macOS apps. We do recommend xcnotary which is also available as a precompiled binary

Build steps

  1. Your Qt Creator project must have two separate build configurations for each Qt kit:

Compile release builds of your app for both 5.15 and 5.15-arm kits. Binaries should be located in different folders e.g. release/youApp.app and release-arm/youApp.app. 2. Once both binaries are compiled, run macdeployqt on both to integrate correspondent Qt frameworks:

macdeployqt "release/youApp.app" -verbose=1 -qtdir=/usr/local/Qt-5.15.8
macdeployqt "release-arm/youApp.app" -verbose=1 -qtdir=/usr/local/Qt-5.15.8-arm

  1. Run makeuniversal to merge folders into a universal binary:

makeuniversal release-universal release release-arm

  1. Sign the universal binary:

codesign --remove-signature youApp.app # for some reason required for arm64
codesign -v --deep youApp.app -s "Developer ID..." -o runtime --entitlements codesign_entitlements.plist

We use codesign_entitlements.plist to disable Library Validation Entitlement.

  1. Notarize the binary using xcnotary:

xcnotary notarize youApp.app --developer-account your@apple.id --developer-password-keychain-item your_notarize_k

It's supposed that the your_notarize_k keychain item already added:

xcrun altool --store-password-in-keychain-item your_notarize_k -u your@apple.id -p paswd

Automation

Internally we have deploy.prj file to include in a Qt .pro file that uses QMAKE_POST_LINK to run macdeployqt, makeuniversal and xcnotary. Deliberately we don't publish our automation scripts yet, they should be more polished and universal.

Misc

For reference you can use our build scripts for Qt 5.15.2 and also some custom macOS-related patches applied.

About

Create macOS universal binaries of your Qt apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published