Create macOS universal binaries of your Qt apps

Overview

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 are currently deploying macOS versions of our apps. We hope that it can be useful for other indie developers and the Qt development community. Let's also hope that Qt Creator will simplify things in future (QTBUG-85279).

The build process takes place on Intel machine using Qt 5.15.2 (migrating to Qt 6 is not possible for us because it doesn't support macOS 10.13 and Windows 7). Currently we're using macOS 10.15.7 (Catalina) and XCode 12.4.

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.2
  • Qt built for arm64 using the QMAKE_APPLE_DEVICE_ARCHS=arm64 configure switch and -prefix /usr/local/Qt-5.15.2-arm to install it to /usr/local/Qt-5.15.2-arm
  • 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 recommended xcnotary which is also available as a precompiled binary

Build steps

  1. Compile release configurations of your app for both arm64 and x86_64. They should be located in different folders e.g. release/youApp.app and release-arm/youApp.app. Use Qt Creator different kits and build configurations to compile for x86_64 and arm64 binaries of your app separately. See example screenshots for more information.
  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.2
macdeployqt "release-arm/youApp.app" -verbose=1 -qtdir=/usr/local/Qt-5.15.2-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 [email protected] --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 [email protected] -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.

Issues
  • PlugIns not being copied by your macdeployqt

    PlugIns not being copied by your macdeployqt

    Hi,

    I have just tried your process for creating a universal binary and I noticed that none of the PlugIns are copied for either the x64 and arm64 builds.

    I tried the original macdeployqt on the x64 build and that then correctly created the PlugIns directory.

    Any ideas?

    Cheers

    Phil

    opened by m0vse 2
  • compiling qt_arm on intel Mac encounter

    compiling qt_arm on intel Mac encounter "Bad CPU type in executable"

    My configure command is

    ./configure -prefix /opt/local/Qt_arm -release -opensource -opengl -nomake examples -nomake tests QMAKE_APPLE_DEVICE_ARCHS=arm64
    

    and when running

    make
    

    I got

    make[3]: /Users/zihanwu/qt5/qtbase/bin/moc: Bad CPU type in executable
    make[3]: *** [.moc/moc_qabstractanimation.cpp] Error 1
    make[3]: *** Waiting for unfinished jobs....
    make[2]: *** [sub-corelib-make_first] Error 2
    make[1]: *** [sub-src-make_first] Error 2
    make: *** [module-qtbase-make_first] Error 2
    

    Do you have any ideas about this? Thank you!

    opened by wzh4464 1
Owner
CrystalIDEA Software
CrystalIDEA Software
A library to create Windows, macOS, and Linux applications.

LAF: The Lost Application Framework A library to create Windows, macOS, and Linux applications. This library is under active development so we don't p

Aseprite 191 Aug 7, 2022
A library for creating native cross-platform GUI apps

Yue A library for creating native cross-platform GUI apps. Getting started Documentations FAQ Development Examples Sample apps (with screenshots) Muba

Yue 2.8k Aug 9, 2022
DeskGap is a framework for building cross-platform desktop apps with web technologies (JavaScript, HTML and CSS).

A cross-platform desktop app framework based on Node.js and the system webview

Wang, Chi 1.8k Aug 7, 2022
Lets try out a few ways to easily create a modern Win32 UI app

UI-Experiments Lets try out a few ways to easily create a modern Win32 UI app This is a VS2019 solution with a handful of single projects, each one tr

Tammo 'kb' Hinrichs 21 Dec 6, 2021
HoI4 Modding Tool That Does It All! Now with a QT based GUI, all your work wil be easier!

Kadaif - HoI4 Modding Tool Kadaif is a cross-platform tool meant to help you make mods for Hearts of Iron IV. With VSCode and all it's extensions, man

null 1 Dec 28, 2021
Daily Quotes is an app extension for the Droptop Four bar that displays Daily Quotes on your bar.

Daily Quotes Daily Quotes is an app extension for the Droptop Four bar that displays Daily Quotes on your bar. · · · · Table of contents Click to expa

Bunz 1 May 4, 2022
Simple C++ script that will move the mouse pointer lighthly on the screen, perfect to prank your friends.

tembleke Simple script written in C++ that when it is executed, the mouse pointer moves lighthly above the screen. I have made this script in order to

viic 1 Oct 28, 2021
Latte is a dock based on plasma frameworks that provides an elegant and intuitive experience for your tasks and plasmoids.

Latte is a dock based on plasma frameworks that provides an elegant and intuitive experience for your tasks and plasmoids. It animates its contents by using parabolic zoom effect and trys to be there only when it is needed.

KDE GitHub Mirror 1.2k Aug 5, 2022
The HorusUI library allows you to quickly develop GUIs for your applications by leveraging the ease of use provided by immediate mode GUI concepts.

Immediate Mode Graphical User Interface for Tools OVERVIEW The HorusUI library allows you to quickly develop GUIs for your applications by leveraging

null 131 Jul 13, 2022
A simple C++ ImGui loader base you can use for all your projects that need a login / register page.

C++ Loader Base ??️ What is this? ⚡ This is a very simple base I made for projects that require a login / register page that use ImGui. ??️ Screenshot

Alfie 17 Jul 23, 2022
A Script to thin Universal Apps on macOS quickly

UBThinner A Script to thin Universal Apps on macOS quickly. It traverses through the given folder recursively, identifies any universal binaries and t

Arm 2 Dec 26, 2021
Universal binaries for Linux.

FatELF The latest information about FatELF can be found at https://icculus.org/fatelf/ What is this? FatELF is a simple file format that allows you to

Ryan C. Gordon 32 May 22, 2022
OS X command line tool to inject Frameworks and dylibs on mach-o binaries (iOS & Mac Apps).

macho-inject OS X command line tool to inject Frameworks and dylibs on mach-o binaries. It does the injection of the framework and the codesigning. It

Jon Gabilondo 5 Jul 29, 2022
Background Music, a macOS audio utility: automatically pause your music, set individual apps' volumes and record system audio.

Background Music macOS audio utility Overview Auto-pause music Application volume Recording system audio Download Build and Install Uninstall Troubles

Kyle Neideck 11.8k Aug 6, 2022
Decrypt FairPlay encrypted executable binaries on macOS

UnFairPlay Decrypt FairPlay encrypted binaries on macOS when SIP-enabled. By mapping an executable as r-x and then using mremap_encrypted on the encry

subdiox 58 Jul 30, 2022
A universal way to create a noclip mod in Unity games (Mono/IIL2CPP)

Universal-Unity-NoClip This projects aim to show how a noclip mod can be created in any unity game, regardless if its using an il2cpp or mono backend.

Jonah 21 Jul 24, 2022
An app that allows you to edit/create apps in Dash

AppAdder On Ubuntu, have you ever run a program or AppImage and the app not had an icon? This is a personal pet peeve. I've used AppImageLauncher to i

Camden 5 Jun 25, 2022
A header maker, this project will create your header file with all your declaration in

Headermaker Install: git clone https://github.com/rmechety42/Headermaker.git cd Headermaker make install Usage: Headermaker src_folder_you_want_to

Rayan Mechety 35 Aug 1, 2022
UnhookMe is an universal Windows API resolver & unhooker addressing problem of invoking unmonitored system calls from within of your Red Teams malware

UnhookMe - Dynamically unhooking imports resolver In the era of intrusive AVs and EDRs that introduce hot-patches to the running processes for their e

Mariusz B. 299 Aug 6, 2022
Utility to install kexts, Frameworks and PrivateFrameworks in the System of macOS. For macOS Monterey 12 and Big Sur 11

Command-Line-SnapShot-Mounter Credit: chris1111 Apple This utility uses the macOS terminal Command Line SnapShot Mounter is an utility that allows you

chris1111 19 Jul 15, 2022
Macos-arm64-emulation - A guide for emulating macOS arm64e on an x86-based host.

macos-arm64-emulation Use the following guide to download and configure all of the necessary tools and files for emulating the macOS arm64e kernel. Th

Cylance 218 Jul 28, 2022
Free open-source modern C++17 / C++20 framework to create console, forms (GUI like WinForms) and unit test applications on Microsoft Windows, Apple macOS and Linux.

xtd Modern C++17/20 framework to create console (CLI), forms (GUI like WinForms) and tunit (unit tests like Microsoft Unit Testing Framework) applicat

Gammasoft 344 Aug 8, 2022
Free open-source modern C++17 / C++20 framework to create console, forms (GUI like WinForms) and unit test applications on Microsoft Windows, Apple macOS and Linux.

xtd Modern C++17/20 framework to create console (CLI), forms (GUI like WinForms) and tunit (unit tests like Microsoft Unit Testing Framework) applicat

Gammasoft 341 Aug 4, 2022
A library to create Windows, macOS, and Linux applications.

LAF: The Lost Application Framework A library to create Windows, macOS, and Linux applications. This library is under active development so we don't p

Aseprite 191 Aug 7, 2022
Create a calculator of any kind in any language, create a pr.

calculators Create a calculator of any kind in any language, create a pr. Create a calculator of any type using the programming language of your choic

Akshay Gautam 2 Dec 1, 2021
This tool allow you to create / load / edit models used for create a cinematic in game for World of Warcraft 3.3.5 version

CameraCinematic - Discord Introduction This tool allow you to create / load / edit models used for create a cinematic in game for World of Warcraft 3.

Intemporel 9 Mar 14, 2022
SymQEMU: Compilation-based symbolic execution for binaries

SymQEMU This is SymQEMU, a binary-only symbolic executor based on QEMU and SymCC. It currently extends QEMU 4.1.1 and works with the most recent versi

null 206 Jul 29, 2022
Powerful automated tool for reverse engineering Unity IL2CPP binaries

Powerful automated tool for reverse engineering Unity IL2CPP binaries

Katy 1.9k Aug 5, 2022
Execute MachO binaries in memory using CGo

Execute Thin Mach-O Binaries in Memory This is a CGo implementation of the initial technique put forward by Stephanie Archibald in her blog, Running E

Dwight Hohnstein 63 Aug 1, 2022