├── README.md ├── bin ├── macdeployqt ├── makeuniversal └── xcnotary ├── etc └── codesign_entitlements.plist ├── macdeployqt_src ├── macdeployqt.pro ├── main.cpp ├── shared.cpp └── shared.h └── screens ├── qt_configurations.png ├── qt_kits.png └── qt_versions.png /README.md: -------------------------------------------------------------------------------- 1 | # Update: the tutorial is outdated 2 | 3 | Qt Group open sourced [Qt 5.15.9](https://download.qt.io/official_releases/qt/5.15/5.15.9/) with macOS universal binaries support. 4 | 5 | If you're still interested for some reason, proceed reading. 6 | 7 | # Deploying macOS universal binaries using Qt 5.15.8 8 | 9 | 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. 10 | 11 | This article explains how we at CrystalIDEA used to deploy macOS versions of [our apps](https://crystalidea.com/) (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). 12 | 13 | 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. 14 | 15 | **Disclaimer**: the described process is unlikely to be optimal, any improvement ideas and comments are welcome. 16 | 17 | ## Prerequisites 18 | 19 | - Qt built for x86_64. It's installed (by default) to /usr/local/Qt-5.15.8 20 | - 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 21 | - Qt Creator should have these two Qt versions added and two corresponding kits for each 22 | 23 | ![](/screens/qt_versions.png) 24 | 25 | ![](/screens/qt_kits.png) 26 | 27 | - Our modified version of [macdeployqt](macdeployqt_src) with support of the `-qtdir` switch that speficies actual Qt directory. You can compile it yourself or download our [precompiled binary](bin/macdeployqt) (it has no dependencies as Qt is statically linked) 28 | - [makeuniversal](https://github.com/nedrysoft/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](bin/makeuniversal) with zero dependencies 29 | - A tool to notarize macOS apps. We do recommend [xcnotary](https://github.com/akeru-inc/xcnotary) which is also available as a [precompiled binary](bin/xcnotary) 30 | 31 | ## Build steps 32 | 33 | 1. Your Qt Creator project must have two separate build configurations for each Qt kit: 34 | 35 | ![](/screens/qt_configurations.png) 36 | 37 | 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*. 38 | 2. Once both binaries are compiled, run **macdeployqt** on both to integrate correspondent Qt frameworks: 39 | 40 | `macdeployqt "release/youApp.app" -verbose=1 -qtdir=/usr/local/Qt-5.15.8`\ 41 | `macdeployqt "release-arm/youApp.app" -verbose=1 -qtdir=/usr/local/Qt-5.15.8-arm` 42 | 43 | 3. Run **makeuniversal** to merge folders into a universal binary: 44 | 45 | `makeuniversal release-universal release release-arm` 46 | 47 | 4. Sign the universal binary: 48 | 49 | `codesign --remove-signature youApp.app # for some reason required for arm64`\ 50 | `codesign -v --deep youApp.app -s "Developer ID..." -o runtime --entitlements codesign_entitlements.plist` 51 | 52 | We use [codesign_entitlements.plist](etc/codesign_entitlements.plist) to disable [Library Validation Entitlement](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_cs_disable-library-validation?language=objc). 53 | 54 | 5. Notarize the binary using **xcnotary**: 55 | 56 | `xcnotary notarize youApp.app --developer-account your@apple.id --developer-password-keychain-item your_notarize_k` 57 | 58 | It's supposed that the *your_notarize_k* keychain item already added: 59 | 60 | `xcrun altool --store-password-in-keychain-item your_notarize_k -u your@apple.id -p paswd` 61 | 62 | ## Automation 63 | 64 | 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. 65 | 66 | ## Misc 67 | 68 | For reference you can use our [build scripts for Qt 5.15.2](https://github.com/crystalidea/qt-build-tools/tree/master/5.15.2) and also some custom macOS-related patches applied. 69 | -------------------------------------------------------------------------------- /bin/macdeployqt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crystalidea/macdeployqt-universal/6f4e11da4a3675c1696d83a6c08ee9d7a2661461/bin/macdeployqt -------------------------------------------------------------------------------- /bin/makeuniversal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crystalidea/macdeployqt-universal/6f4e11da4a3675c1696d83a6c08ee9d7a2661461/bin/makeuniversal -------------------------------------------------------------------------------- /bin/xcnotary: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crystalidea/macdeployqt-universal/6f4e11da4a3675c1696d83a6c08ee9d7a2661461/bin/xcnotary -------------------------------------------------------------------------------- /etc/codesign_entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.cs.disable-library-validation 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macdeployqt_src/macdeployqt.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | 3 | CONFIG += c++11 console 4 | CONFIG -= app_bundle 5 | 6 | SOURCES += main.cpp shared.cpp 7 | QT = core 8 | LIBS += -framework CoreFoundation 9 | 10 | DEFINES -= QT_DEPRECATED_WARNINGS 11 | -------------------------------------------------------------------------------- /macdeployqt_src/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the tools applications of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** GNU General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU 19 | ** General Public License version 3 as published by the Free Software 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 21 | ** included in the packaging of this file. Please review the following 22 | ** information to ensure the GNU General Public License requirements will 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 24 | ** 25 | ** $QT_END_LICENSE$ 26 | ** 27 | ****************************************************************************/ 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "shared.h" 34 | 35 | int main(int argc, char **argv) 36 | { 37 | QCoreApplication app(argc, argv); 38 | 39 | QString appBundlePath; 40 | if (argc > 1) 41 | appBundlePath = QString::fromLocal8Bit(argv[1]); 42 | 43 | if (argc < 2 || appBundlePath.startsWith("-")) { 44 | qDebug() << "Usage: macdeployqt app-bundle [options]"; 45 | qDebug() << ""; 46 | qDebug() << "Options:"; 47 | qDebug() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug"; 48 | qDebug() << " -no-plugins : Skip plugin deployment"; 49 | qDebug() << " -dmg : Create a .dmg disk image"; 50 | qDebug() << " -no-strip : Don't run 'strip' on the binaries"; 51 | qDebug() << " -use-debug-libs : Deploy with debug versions of frameworks and plugins (implies -no-strip)"; 52 | qDebug() << " -executable= : Let the given executable use the deployed frameworks too"; 53 | qDebug() << " -qmldir= : Scan for QML imports in the given path"; 54 | qDebug() << " -qmlimport= : Add the given path to the QML module search locations"; 55 | qDebug() << " -always-overwrite : Copy files even if the target file exists"; 56 | qDebug() << " -codesign= : Run codesign with the given identity on all executables"; 57 | qDebug() << " -hardened-runtime : Enable Hardened Runtime when code signing"; 58 | qDebug() << " -timestamp : Include a secure timestamp when code signing (requires internet connection)"; 59 | qDebug() << " -sign-for-notarization=: Activate the necessary options for notarization (requires internet connection)"; 60 | qDebug() << " -appstore-compliant : Skip deployment of components that use private API"; 61 | qDebug() << " -libpath= : Add the given path to the library search path"; 62 | qDebug() << " -fs= : Set the filesystem used for the .dmg disk image (defaults to HFS+)"; 63 | qDebug() << ""; 64 | qDebug() << "macdeployqt takes an application bundle as input and makes it"; 65 | qDebug() << "self-contained by copying in the Qt frameworks and plugins that"; 66 | qDebug() << "the application uses."; 67 | qDebug() << ""; 68 | qDebug() << "Plugins related to a framework are copied in with the"; 69 | qDebug() << "framework. The accessibility, image formats, and text codec"; 70 | qDebug() << "plugins are always copied, unless \"-no-plugins\" is specified."; 71 | qDebug() << ""; 72 | qDebug() << "Qt plugins may use private API and will cause the app to be"; 73 | qDebug() << "rejected from the Mac App store. MacDeployQt will print a warning"; 74 | qDebug() << "when known incompatible plugins are deployed. Use -appstore-compliant "; 75 | qDebug() << "to skip these plugins. Currently two SQL plugins are known to"; 76 | qDebug() << "be incompatible: qsqlodbc and qsqlpsql."; 77 | qDebug() << ""; 78 | qDebug() << "See the \"Deploying Applications on OS X\" topic in the"; 79 | qDebug() << "documentation for more information about deployment on OS X."; 80 | 81 | return 1; 82 | } 83 | 84 | appBundlePath = QDir::cleanPath(appBundlePath); 85 | 86 | if (QDir().exists(appBundlePath) == false) { 87 | qDebug() << "Error: Could not find app bundle" << appBundlePath; 88 | return 1; 89 | } 90 | 91 | bool plugins = true; 92 | bool dmg = false; 93 | QByteArray filesystem("HFS+"); 94 | bool useDebugLibs = false; 95 | extern bool runStripEnabled; 96 | extern bool alwaysOwerwriteEnabled; 97 | extern QStringList librarySearchPath; 98 | QStringList additionalExecutables; 99 | bool qmldirArgumentUsed = false; 100 | QStringList qmlDirs; 101 | QStringList qmlImportPaths; 102 | extern bool runCodesign; 103 | extern QString codesignIdentiy; 104 | extern bool hardenedRuntime; 105 | extern bool appstoreCompliant; 106 | extern bool deployFramework; 107 | extern bool secureTimestamp; 108 | extern QString customQtPath; 109 | 110 | for (int i = 2; i < argc; ++i) { 111 | QByteArray argument = QByteArray(argv[i]); 112 | if (argument == QByteArray("-no-plugins")) { 113 | LogDebug() << "Argument found:" << argument; 114 | plugins = false; 115 | } else if (argument == QByteArray("-dmg")) { 116 | LogDebug() << "Argument found:" << argument; 117 | dmg = true; 118 | } else if (argument == QByteArray("-no-strip")) { 119 | LogDebug() << "Argument found:" << argument; 120 | runStripEnabled = false; 121 | } else if (argument == QByteArray("-use-debug-libs")) { 122 | LogDebug() << "Argument found:" << argument; 123 | useDebugLibs = true; 124 | runStripEnabled = false; 125 | } else if (argument.startsWith(QByteArray("-verbose"))) { 126 | LogDebug() << "Argument found:" << argument; 127 | int index = argument.indexOf("="); 128 | bool ok = false; 129 | int number = argument.mid(index+1).toInt(&ok); 130 | if (!ok) 131 | LogError() << "Could not parse verbose level"; 132 | else 133 | logLevel = number; 134 | } else if (argument.startsWith(QByteArray("-executable"))) { 135 | LogDebug() << "Argument found:" << argument; 136 | int index = argument.indexOf('='); 137 | if (index == -1) 138 | LogError() << "Missing executable path"; 139 | else 140 | additionalExecutables << argument.mid(index+1); 141 | } else if (argument.startsWith(QByteArray("-qmldir"))) { 142 | LogDebug() << "Argument found:" << argument; 143 | qmldirArgumentUsed = true; 144 | int index = argument.indexOf('='); 145 | if (index == -1) 146 | LogError() << "Missing qml directory path"; 147 | else 148 | qmlDirs << argument.mid(index+1); 149 | } else if (argument.startsWith(QByteArray("-qtdir"))) { 150 | LogDebug() << "Argument found:" << argument; 151 | int index = argument.indexOf('='); 152 | if (index == -1) 153 | LogError() << "Missing qt directory path"; 154 | else 155 | customQtPath = argument.mid(index+1); 156 | } else if (argument.startsWith(QByteArray("-qmlimport"))) { 157 | LogDebug() << "Argument found:" << argument; 158 | int index = argument.indexOf('='); 159 | if (index == -1) 160 | LogError() << "Missing qml import path"; 161 | else 162 | qmlImportPaths << argument.mid(index+1); 163 | } else if (argument.startsWith(QByteArray("-libpath"))) { 164 | LogDebug() << "Argument found:" << argument; 165 | int index = argument.indexOf('='); 166 | if (index == -1) 167 | LogError() << "Missing library search path"; 168 | else 169 | librarySearchPath << argument.mid(index+1); 170 | } else if (argument == QByteArray("-always-overwrite")) { 171 | LogDebug() << "Argument found:" << argument; 172 | alwaysOwerwriteEnabled = true; 173 | } else if (argument.startsWith(QByteArray("-codesign"))) { 174 | LogDebug() << "Argument found:" << argument; 175 | int index = argument.indexOf("="); 176 | if (index < 0 || index >= argument.size()) { 177 | LogError() << "Missing code signing identity"; 178 | } else { 179 | runCodesign = true; 180 | codesignIdentiy = argument.mid(index+1); 181 | } 182 | } else if (argument.startsWith(QByteArray("-sign-for-notarization"))) { 183 | LogDebug() << "Argument found:" << argument; 184 | int index = argument.indexOf("="); 185 | if (index < 0 || index >= argument.size()) { 186 | LogError() << "Missing code signing identity"; 187 | } else { 188 | runCodesign = true; 189 | hardenedRuntime = true; 190 | secureTimestamp = true; 191 | codesignIdentiy = argument.mid(index+1); 192 | } 193 | } else if (argument.startsWith(QByteArray("-hardened-runtime"))) { 194 | LogDebug() << "Argument found:" << argument; 195 | hardenedRuntime = true; 196 | } else if (argument.startsWith(QByteArray("-timestamp"))) { 197 | LogDebug() << "Argument found:" << argument; 198 | secureTimestamp = true; 199 | } else if (argument == QByteArray("-appstore-compliant")) { 200 | LogDebug() << "Argument found:" << argument; 201 | appstoreCompliant = true; 202 | 203 | // Undocumented option, may not work as intented 204 | } else if (argument == QByteArray("-deploy-framework")) { 205 | LogDebug() << "Argument found:" << argument; 206 | deployFramework = true; 207 | 208 | } else if (argument.startsWith(QByteArray("-fs"))) { 209 | LogDebug() << "Argument found:" << argument; 210 | int index = argument.indexOf('='); 211 | if (index == -1) 212 | LogError() << "Missing filesystem type"; 213 | else 214 | filesystem = argument.mid(index+1); 215 | } else if (argument.startsWith("-")) { 216 | LogError() << "Unknown argument" << argument << "\n"; 217 | return 1; 218 | } 219 | } 220 | 221 | if (customQtPath.isEmpty()) { 222 | LogError() << "Cannot proceed without Qt dir"; 223 | return 1; 224 | } 225 | 226 | LogNormal() << "Qt deploy dir:" << customQtPath; 227 | 228 | DeploymentInfo deploymentInfo = deployQtFrameworks(appBundlePath, additionalExecutables, useDebugLibs); 229 | 230 | if (deploymentInfo.isDebug) 231 | useDebugLibs = true; 232 | 233 | if (deployFramework && deploymentInfo.isFramework) 234 | fixupFramework(appBundlePath); 235 | 236 | // Convenience: Look for .qml files in the current directoty if no -qmldir specified. 237 | if (qmlDirs.isEmpty()) { 238 | QDir dir; 239 | if (!dir.entryList(QStringList() << QStringLiteral("*.qml")).isEmpty()) { 240 | qmlDirs += QStringLiteral("."); 241 | } 242 | } 243 | 244 | if (!qmlDirs.isEmpty()) { 245 | bool ok = deployQmlImports(appBundlePath, deploymentInfo, qmlDirs, qmlImportPaths); 246 | if (!ok && qmldirArgumentUsed) 247 | return 1; // exit if the user explicitly asked for qml import deployment 248 | 249 | // Update deploymentInfo.deployedFrameworks - the QML imports 250 | // may have brought in extra frameworks as dependencies. 251 | deploymentInfo.deployedFrameworks += findAppFrameworkNames(appBundlePath); 252 | deploymentInfo.deployedFrameworks = deploymentInfo.deployedFrameworks.toSet().toList(); 253 | } 254 | 255 | if (plugins && !deploymentInfo.qtPath.isEmpty()) { 256 | deploymentInfo.pluginPath = deploymentInfo.qtPath + "/plugins"; 257 | LogNormal(); 258 | deployPlugins(appBundlePath, deploymentInfo, useDebugLibs); 259 | createQtConf(appBundlePath); 260 | } 261 | 262 | if (runStripEnabled) 263 | stripAppBinary(appBundlePath); 264 | 265 | if (runCodesign) 266 | codesign(codesignIdentiy, appBundlePath); 267 | 268 | if (dmg) { 269 | LogNormal(); 270 | createDiskImage(appBundlePath, filesystem); 271 | } 272 | 273 | return 0; 274 | } 275 | 276 | -------------------------------------------------------------------------------- /macdeployqt_src/shared.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the tools applications of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** GNU General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU 19 | ** General Public License version 3 as published by the Free Software 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 21 | ** included in the packaging of this file. Please review the following 22 | ** information to ensure the GNU General Public License requirements will 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 24 | ** 25 | ** $QT_END_LICENSE$ 26 | ** 27 | ****************************************************************************/ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include "shared.h" 46 | 47 | #ifdef Q_OS_DARWIN 48 | #include 49 | #endif 50 | 51 | bool runStripEnabled = true; 52 | bool alwaysOwerwriteEnabled = false; 53 | bool runCodesign = false; 54 | QStringList librarySearchPath; 55 | QString codesignIdentiy; 56 | QString extraEntitlements; 57 | QString customQtPath; 58 | bool hardenedRuntime = false; 59 | bool secureTimestamp = false; 60 | bool appstoreCompliant = false; 61 | int logLevel = 1; 62 | bool deployFramework = false; 63 | 64 | using std::cout; 65 | using std::endl; 66 | 67 | bool operator==(const FrameworkInfo &a, const FrameworkInfo &b) 68 | { 69 | return ((a.frameworkPath == b.frameworkPath) && (a.binaryPath == b.binaryPath)); 70 | } 71 | 72 | QDebug operator<<(QDebug debug, const FrameworkInfo &info) 73 | { 74 | debug << "Framework name" << info.frameworkName << "\n"; 75 | debug << "Framework directory" << info.frameworkDirectory << "\n"; 76 | debug << "Framework path" << info.frameworkPath << "\n"; 77 | debug << "Binary directory" << info.binaryDirectory << "\n"; 78 | debug << "Binary name" << info.binaryName << "\n"; 79 | debug << "Binary path" << info.binaryPath << "\n"; 80 | debug << "Version" << info.version << "\n"; 81 | debug << "Install name" << info.installName << "\n"; 82 | debug << "Deployed install name" << info.deployedInstallName << "\n"; 83 | debug << "Source file Path" << info.sourceFilePath << "\n"; 84 | debug << "Framework Destination Directory (relative to bundle)" << info.frameworkDestinationDirectory << "\n"; 85 | debug << "Binary Destination Directory (relative to bundle)" << info.binaryDestinationDirectory << "\n"; 86 | 87 | return debug; 88 | } 89 | 90 | const QString bundleFrameworkDirectory = "Contents/Frameworks"; 91 | 92 | inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info) 93 | { 94 | debug << "Application bundle path" << info.path << "\n"; 95 | debug << "Binary path" << info.binaryPath << "\n"; 96 | debug << "Additional libraries" << info.libraryPaths << "\n"; 97 | return debug; 98 | } 99 | 100 | bool copyFilePrintStatus(const QString &from, const QString &to) 101 | { 102 | if (QFile(to).exists()) { 103 | if (alwaysOwerwriteEnabled) { 104 | QFile(to).remove(); 105 | } else { 106 | qDebug() << "File exists, skip copy:" << to; 107 | return false; 108 | } 109 | } 110 | 111 | if (QFile::copy(from, to)) { 112 | QFile dest(to); 113 | dest.setPermissions(dest.permissions() | QFile::WriteOwner | QFile::WriteUser); 114 | LogNormal() << " copied:" << from; 115 | LogNormal() << " to" << to; 116 | 117 | // The source file might not have write permissions set. Set the 118 | // write permission on the target file to make sure we can use 119 | // install_name_tool on it later. 120 | QFile toFile(to); 121 | if (toFile.permissions() & QFile::WriteOwner) 122 | return true; 123 | 124 | if (!toFile.setPermissions(toFile.permissions() | QFile::WriteOwner)) { 125 | LogError() << "Failed to set u+w permissions on target file: " << to; 126 | return false; 127 | } 128 | 129 | return true; 130 | } else { 131 | LogError() << "file copy failed from" << from; 132 | LogError() << " to" << to; 133 | return false; 134 | } 135 | } 136 | 137 | bool linkFilePrintStatus(const QString &file, const QString &link) 138 | { 139 | if (QFile(link).exists()) { 140 | if (QFile(link).symLinkTarget().isEmpty()) 141 | LogError() << link << "exists but it's a file."; 142 | else 143 | LogNormal() << "Symlink exists, skipping:" << link; 144 | return false; 145 | } else if (QFile::link(file, link)) { 146 | LogNormal() << " symlink" << link; 147 | LogNormal() << " points to" << file; 148 | return true; 149 | } else { 150 | LogError() << "failed to symlink" << link; 151 | LogError() << " to" << file; 152 | return false; 153 | } 154 | } 155 | 156 | void patch_debugInInfoPlist(const QString &infoPlistPath) 157 | { 158 | // Older versions of qmake may have the "_debug" binary as 159 | // the value for CFBundleExecutable. Remove it. 160 | QFile infoPlist(infoPlistPath); 161 | infoPlist.open(QIODevice::ReadOnly); 162 | QByteArray contents = infoPlist.readAll(); 163 | infoPlist.close(); 164 | infoPlist.open(QIODevice::WriteOnly | QIODevice::Truncate); 165 | contents.replace("_debug", ""); // surely there are no legit uses of "_debug" in an Info.plist 166 | infoPlist.write(contents); 167 | } 168 | 169 | OtoolInfo findDependencyInfo(const QString &binaryPath) 170 | { 171 | OtoolInfo info; 172 | info.binaryPath = binaryPath; 173 | 174 | LogDebug() << "Using otool:"; 175 | LogDebug() << " inspecting" << binaryPath; 176 | QProcess otool; 177 | otool.start("otool", QStringList() << "-L" << binaryPath); 178 | otool.waitForFinished(); 179 | 180 | if (otool.exitStatus() != QProcess::NormalExit || otool.exitCode() != 0) { 181 | LogError() << otool.readAllStandardError(); 182 | return info; 183 | } 184 | 185 | static const QRegularExpression regexp(QStringLiteral( 186 | "^\\t(.+) \\(compatibility version (\\d+\\.\\d+\\.\\d+), " 187 | "current version (\\d+\\.\\d+\\.\\d+)(, weak)?\\)$")); 188 | 189 | QString output = otool.readAllStandardOutput(); 190 | QStringList outputLines = output.split("\n", Qt::SkipEmptyParts); 191 | if (outputLines.size() < 2) { 192 | LogError() << "Could not parse otool output:" << output; 193 | return info; 194 | } 195 | 196 | outputLines.removeFirst(); // remove line containing the binary path 197 | if (binaryPath.contains(".framework/") || binaryPath.endsWith(".dylib")) { 198 | const auto match = regexp.match(outputLines.first()); 199 | if (match.hasMatch()) { 200 | info.installName = match.captured(1); 201 | info.compatibilityVersion = QVersionNumber::fromString(match.captured(2)); 202 | info.currentVersion = QVersionNumber::fromString(match.captured(3)); 203 | } else { 204 | LogError() << "Could not parse otool output line:" << outputLines.first(); 205 | } 206 | outputLines.removeFirst(); 207 | } 208 | 209 | for (const QString &outputLine : outputLines) { 210 | const auto match = regexp.match(outputLine); 211 | if (match.hasMatch()) { 212 | DylibInfo dylib; 213 | dylib.binaryPath = match.captured(1); 214 | dylib.compatibilityVersion = QVersionNumber::fromString(match.captured(2)); 215 | dylib.currentVersion = QVersionNumber::fromString(match.captured(3)); 216 | info.dependencies << dylib; 217 | } else { 218 | LogError() << "Could not parse otool output line:" << outputLine; 219 | } 220 | } 221 | 222 | return info; 223 | } 224 | 225 | FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundlePath, const QSet &rpaths, bool useDebugLibs) 226 | { 227 | FrameworkInfo info; 228 | QString trimmed = line.trimmed(); 229 | 230 | if (trimmed.isEmpty()) 231 | return info; 232 | 233 | // Don't deploy system libraries. 234 | if (trimmed.startsWith("/System/Library/") || 235 | (trimmed.startsWith("/usr/lib/") && trimmed.contains("libQt") == false) // exception for libQtuitools and libQtlucene 236 | || trimmed.startsWith("@executable_path") || trimmed.startsWith("@loader_path")) 237 | return info; 238 | 239 | // Resolve rpath relative libraries. 240 | if (trimmed.startsWith("@rpath/")) { 241 | QString rpathRelativePath = trimmed.mid(QStringLiteral("@rpath/").length()); 242 | bool foundInsideBundle = false; 243 | foreach (const QString &rpath, rpaths) { 244 | QString path = QDir::cleanPath(rpath + "/" + rpathRelativePath); 245 | // Skip paths already inside the bundle. 246 | if (!appBundlePath.isEmpty()) { 247 | if (QDir::isAbsolutePath(appBundlePath)) { 248 | if (path.startsWith(QDir::cleanPath(appBundlePath) + "/")) { 249 | foundInsideBundle = true; 250 | continue; 251 | } 252 | } else { 253 | if (path.startsWith(QDir::cleanPath(QDir::currentPath() + "/" + appBundlePath) + "/")) { 254 | foundInsideBundle = true; 255 | continue; 256 | } 257 | } 258 | } 259 | // Try again with substituted rpath. 260 | FrameworkInfo resolvedInfo = parseOtoolLibraryLine(path, appBundlePath, rpaths, useDebugLibs); 261 | if (!resolvedInfo.frameworkName.isEmpty() && QFile::exists(resolvedInfo.frameworkPath)) { 262 | resolvedInfo.rpathUsed = rpath; 263 | resolvedInfo.installName = trimmed; 264 | return resolvedInfo; 265 | } 266 | } 267 | if (!rpaths.isEmpty() && !foundInsideBundle) { 268 | LogError() << "Cannot resolve rpath" << trimmed; 269 | LogError() << " using" << rpaths; 270 | } 271 | return info; 272 | } 273 | 274 | enum State {QtPath, FrameworkName, DylibName, Version, FrameworkBinary, End}; 275 | State state = QtPath; 276 | int part = 0; 277 | QString name; 278 | QString qtPath; 279 | QString suffix = useDebugLibs ? "_debug" : ""; 280 | 281 | // Split the line into [Qt-path]/lib/qt[Module].framework/Versions/[Version]/ 282 | QStringList parts = trimmed.split("/"); 283 | while (part < parts.count()) { 284 | const QString currentPart = parts.at(part).simplified() ; 285 | ++part; 286 | if (currentPart == "") 287 | continue; 288 | 289 | if (state == QtPath) { 290 | // Check for library name part 291 | if (part < parts.count() && parts.at(part).contains(".dylib")) { 292 | info.frameworkDirectory += "/" + (qtPath + currentPart + "/").simplified(); 293 | state = DylibName; 294 | continue; 295 | } else if (part < parts.count() && parts.at(part).endsWith(".framework")) { 296 | info.frameworkDirectory += "/" + (qtPath + "lib/").simplified(); 297 | state = FrameworkName; 298 | continue; 299 | } else if (trimmed.startsWith("/") == false) { // If the line does not contain a full path, the app is using a binary Qt package. 300 | QStringList partsCopy = parts; 301 | partsCopy.removeLast(); 302 | foreach (QString path, librarySearchPath) { 303 | if (!path.endsWith("/")) 304 | path += '/'; 305 | QString nameInPath = path + parts.join(QLatin1Char('/')); 306 | if (QFile::exists(nameInPath)) { 307 | info.frameworkDirectory = path + partsCopy.join(QLatin1Char('/')); 308 | break; 309 | } 310 | } 311 | if (currentPart.contains(".framework")) { 312 | if (info.frameworkDirectory.isEmpty()) 313 | info.frameworkDirectory = "/Library/Frameworks/" + partsCopy.join(QLatin1Char('/')); 314 | if (!info.frameworkDirectory.endsWith("/")) 315 | info.frameworkDirectory += "/"; 316 | state = FrameworkName; 317 | --part; 318 | continue; 319 | } else if (currentPart.contains(".dylib")) { 320 | if (info.frameworkDirectory.isEmpty()) 321 | info.frameworkDirectory = "/usr/lib/" + partsCopy.join(QLatin1Char('/')); 322 | if (!info.frameworkDirectory.endsWith("/")) 323 | info.frameworkDirectory += "/"; 324 | state = DylibName; 325 | --part; 326 | continue; 327 | } 328 | } 329 | qtPath += (currentPart + "/"); 330 | 331 | } if (state == FrameworkName) { 332 | // remove ".framework" 333 | name = currentPart; 334 | name.chop(QString(".framework").length()); 335 | info.isDylib = false; 336 | info.frameworkName = currentPart; 337 | state = Version; 338 | ++part; 339 | continue; 340 | } if (state == DylibName) { 341 | name = currentPart; 342 | info.isDylib = true; 343 | info.frameworkName = name; 344 | info.binaryName = name.contains(suffix) ? name : name.left(name.indexOf('.')) + suffix + name.mid(name.indexOf('.')); 345 | info.deployedInstallName = "@executable_path/../Frameworks/" + info.binaryName; 346 | info.frameworkPath = info.frameworkDirectory + info.binaryName; 347 | info.sourceFilePath = info.frameworkPath; 348 | info.frameworkDestinationDirectory = bundleFrameworkDirectory + "/"; 349 | info.binaryDestinationDirectory = info.frameworkDestinationDirectory; 350 | info.binaryDirectory = info.frameworkDirectory; 351 | info.binaryPath = info.frameworkPath; 352 | state = End; 353 | ++part; 354 | continue; 355 | } else if (state == Version) { 356 | info.version = currentPart; 357 | info.binaryDirectory = "Versions/" + info.version; 358 | info.frameworkPath = info.frameworkDirectory + info.frameworkName; 359 | info.frameworkDestinationDirectory = bundleFrameworkDirectory + "/" + info.frameworkName; 360 | info.binaryDestinationDirectory = info.frameworkDestinationDirectory + "/" + info.binaryDirectory; 361 | state = FrameworkBinary; 362 | } else if (state == FrameworkBinary) { 363 | info.binaryName = currentPart.contains(suffix) ? currentPart : currentPart + suffix; 364 | info.binaryPath = "/" + info.binaryDirectory + "/" + info.binaryName; 365 | info.deployedInstallName = "@executable_path/../Frameworks/" + info.frameworkName + info.binaryPath; 366 | info.sourceFilePath = info.frameworkPath + info.binaryPath; 367 | state = End; 368 | } else if (state == End) { 369 | break; 370 | } 371 | } 372 | 373 | if (!info.sourceFilePath.isEmpty() && QFile::exists(info.sourceFilePath)) { 374 | info.installName = findDependencyInfo(info.sourceFilePath).installName; 375 | if (info.installName.startsWith("@rpath/")) 376 | info.deployedInstallName = info.installName; 377 | } 378 | 379 | return info; 380 | } 381 | 382 | QString findAppBinary(const QString &appBundlePath) 383 | { 384 | QString binaryPath; 385 | 386 | #ifdef Q_OS_DARWIN 387 | CFStringRef bundlePath = appBundlePath.toCFString(); 388 | CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath, 389 | kCFURLPOSIXPathStyle, true); 390 | CFRelease(bundlePath); 391 | CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, bundleURL); 392 | if (bundle) { 393 | CFURLRef executableURL = CFBundleCopyExecutableURL(bundle); 394 | if (executableURL) { 395 | CFURLRef absoluteExecutableURL = CFURLCopyAbsoluteURL(executableURL); 396 | if (absoluteExecutableURL) { 397 | CFStringRef executablePath = CFURLCopyFileSystemPath(absoluteExecutableURL, 398 | kCFURLPOSIXPathStyle); 399 | if (executablePath) { 400 | binaryPath = QString::fromCFString(executablePath); 401 | CFRelease(executablePath); 402 | } 403 | CFRelease(absoluteExecutableURL); 404 | } 405 | CFRelease(executableURL); 406 | } 407 | CFRelease(bundle); 408 | } 409 | CFRelease(bundleURL); 410 | #endif 411 | 412 | if (QFile::exists(binaryPath)) 413 | return binaryPath; 414 | LogError() << "Could not find bundle binary for" << appBundlePath; 415 | return QString(); 416 | } 417 | 418 | QStringList findAppFrameworkNames(const QString &appBundlePath) 419 | { 420 | QStringList frameworks; 421 | 422 | // populate the frameworks list with QtFoo.framework etc, 423 | // as found in /Contents/Frameworks/ 424 | QString searchPath = appBundlePath + "/Contents/Frameworks/"; 425 | QDirIterator iter(searchPath, QStringList() << QString::fromLatin1("*.framework"), 426 | QDir::Dirs | QDir::NoSymLinks); 427 | while (iter.hasNext()) { 428 | iter.next(); 429 | frameworks << iter.fileInfo().fileName(); 430 | } 431 | 432 | return frameworks; 433 | } 434 | 435 | QStringList findAppFrameworkPaths(const QString &appBundlePath) 436 | { 437 | QStringList frameworks; 438 | QString searchPath = appBundlePath + "/Contents/Frameworks/"; 439 | QDirIterator iter(searchPath, QStringList() << QString::fromLatin1("*.framework"), 440 | QDir::Dirs | QDir::NoSymLinks); 441 | while (iter.hasNext()) { 442 | iter.next(); 443 | frameworks << iter.fileInfo().filePath(); 444 | } 445 | 446 | return frameworks; 447 | } 448 | 449 | QStringList findAppLibraries(const QString &appBundlePath) 450 | { 451 | QStringList result; 452 | // dylibs 453 | QDirIterator iter(appBundlePath, QStringList() << QString::fromLatin1("*.dylib"), 454 | QDir::Files | QDir::NoSymLinks, QDirIterator::Subdirectories); 455 | while (iter.hasNext()) { 456 | iter.next(); 457 | result << iter.fileInfo().filePath(); 458 | } 459 | return result; 460 | } 461 | 462 | QStringList findAppBundleFiles(const QString &appBundlePath, bool absolutePath = false) 463 | { 464 | QStringList result; 465 | 466 | QDirIterator iter(appBundlePath, QStringList() << QString::fromLatin1("*"), 467 | QDir::Files, QDirIterator::Subdirectories); 468 | 469 | while (iter.hasNext()) { 470 | iter.next(); 471 | if (iter.fileInfo().isSymLink()) 472 | continue; 473 | result << (absolutePath ? iter.fileInfo().absoluteFilePath() : iter.fileInfo().filePath()); 474 | } 475 | 476 | return result; 477 | } 478 | 479 | QString findEntitlementsFile(const QString& path) 480 | { 481 | QDirIterator iter(path, QStringList() << QString::fromLatin1("*.entitlements"), 482 | QDir::Files, QDirIterator::Subdirectories); 483 | 484 | while (iter.hasNext()) { 485 | iter.next(); 486 | if (iter.fileInfo().isSymLink()) 487 | continue; 488 | 489 | //return the first entitlements file - only one is used for signing anyway 490 | return iter.fileInfo().absoluteFilePath(); 491 | } 492 | 493 | return QString(); 494 | } 495 | 496 | QList getQtFrameworks(const QList &dependencies, const QString &appBundlePath, const QSet &rpaths, bool useDebugLibs) 497 | { 498 | QList libraries; 499 | for (const DylibInfo &dylibInfo : dependencies) { 500 | FrameworkInfo info = parseOtoolLibraryLine(dylibInfo.binaryPath, appBundlePath, rpaths, useDebugLibs); 501 | if (info.frameworkName.isEmpty() == false) { 502 | LogDebug() << "Adding framework:"; 503 | LogDebug() << info; 504 | libraries.append(info); 505 | } 506 | } 507 | return libraries; 508 | } 509 | 510 | QString resolveDyldPrefix(const QString &path, const QString &loaderPath, const QString &executablePath) 511 | { 512 | if (path.startsWith("@")) { 513 | if (path.startsWith(QStringLiteral("@executable_path/"))) { 514 | // path relative to bundle executable dir 515 | if (QDir::isAbsolutePath(executablePath)) { 516 | return QDir::cleanPath(QFileInfo(executablePath).path() + path.mid(QStringLiteral("@executable_path").length())); 517 | } else { 518 | return QDir::cleanPath(QDir::currentPath() + "/" + 519 | QFileInfo(executablePath).path() + path.mid(QStringLiteral("@executable_path").length())); 520 | } 521 | } else if (path.startsWith(QStringLiteral("@loader_path"))) { 522 | // path relative to loader dir 523 | if (QDir::isAbsolutePath(loaderPath)) { 524 | return QDir::cleanPath(QFileInfo(loaderPath).path() + path.mid(QStringLiteral("@loader_path").length())); 525 | } else { 526 | return QDir::cleanPath(QDir::currentPath() + "/" + 527 | QFileInfo(loaderPath).path() + path.mid(QStringLiteral("@loader_path").length())); 528 | } 529 | } else { 530 | LogError() << "Unexpected prefix" << path; 531 | } 532 | } 533 | return path; 534 | } 535 | 536 | QSet getBinaryRPaths(const QString &path, bool resolve = true, QString executablePath = QString()) 537 | { 538 | QSet rpaths; 539 | 540 | QProcess otool; 541 | otool.start("otool", QStringList() << "-l" << path); 542 | otool.waitForFinished(); 543 | 544 | if (otool.exitCode() != 0) { 545 | LogError() << otool.readAllStandardError(); 546 | } 547 | 548 | if (resolve && executablePath.isEmpty()) { 549 | executablePath = path; 550 | } 551 | 552 | QString output = otool.readAllStandardOutput(); 553 | QStringList outputLines = output.split("\n"); 554 | 555 | for (auto i = outputLines.cbegin(), end = outputLines.cend(); i != end; ++i) { 556 | if (i->contains("cmd LC_RPATH") && ++i != end && 557 | i->contains("cmdsize") && ++i != end) { 558 | const QString &rpathCmd = *i; 559 | int pathStart = rpathCmd.indexOf("path "); 560 | int pathEnd = rpathCmd.indexOf(" ("); 561 | if (pathStart >= 0 && pathEnd >= 0 && pathStart < pathEnd) { 562 | QString rpath = rpathCmd.mid(pathStart + 5, pathEnd - pathStart - 5); 563 | if (resolve) { 564 | rpaths << resolveDyldPrefix(rpath, path, executablePath); 565 | } else { 566 | rpaths << rpath; 567 | } 568 | } 569 | } 570 | } 571 | 572 | return rpaths; 573 | } 574 | 575 | QList getQtFrameworks(const QString &path, const QString &appBundlePath, const QSet &rpaths, bool useDebugLibs) 576 | { 577 | const OtoolInfo info = findDependencyInfo(path); 578 | return getQtFrameworks(info.dependencies, appBundlePath, rpaths + getBinaryRPaths(path), useDebugLibs); 579 | } 580 | 581 | QList getQtFrameworksForPaths(const QStringList &paths, const QString &appBundlePath, const QSet &rpaths, bool useDebugLibs) 582 | { 583 | QList result; 584 | QSet existing; 585 | foreach (const QString &path, paths) { 586 | foreach (const FrameworkInfo &info, getQtFrameworks(path, appBundlePath, rpaths, useDebugLibs)) { 587 | if (!existing.contains(info.frameworkPath)) { // avoid duplicates 588 | existing.insert(info.frameworkPath); 589 | result << info; 590 | } 591 | } 592 | } 593 | return result; 594 | } 595 | 596 | QStringList getBinaryDependencies(const QString executablePath, 597 | const QString &path, 598 | const QList &additionalBinariesContainingRpaths) 599 | { 600 | QStringList binaries; 601 | 602 | const auto dependencies = findDependencyInfo(path).dependencies; 603 | 604 | bool rpathsLoaded = false; 605 | QSet rpaths; 606 | 607 | // return bundle-local dependencies. (those starting with @executable_path) 608 | foreach (const DylibInfo &info, dependencies) { 609 | QString trimmedLine = info.binaryPath; 610 | if (trimmedLine.startsWith("@executable_path/")) { 611 | QString binary = QDir::cleanPath(executablePath + trimmedLine.mid(QStringLiteral("@executable_path/").length())); 612 | if (binary != path) 613 | binaries.append(binary); 614 | } else if (trimmedLine.startsWith("@rpath/")) { 615 | if (!rpathsLoaded) { 616 | rpaths = getBinaryRPaths(path, true, executablePath); 617 | foreach (const QString &binaryPath, additionalBinariesContainingRpaths) { 618 | QSet binaryRpaths = getBinaryRPaths(binaryPath, true); 619 | rpaths += binaryRpaths; 620 | } 621 | rpathsLoaded = true; 622 | } 623 | bool resolved = false; 624 | foreach (const QString &rpath, rpaths) { 625 | QString binary = QDir::cleanPath(rpath + "/" + trimmedLine.mid(QStringLiteral("@rpath/").length())); 626 | LogDebug() << "Checking for" << binary; 627 | if (QFile::exists(binary)) { 628 | binaries.append(binary); 629 | resolved = true; 630 | break; 631 | } 632 | } 633 | if (!resolved && !rpaths.isEmpty()) { 634 | LogError() << "Cannot resolve rpath" << trimmedLine; 635 | LogError() << " using" << rpaths; 636 | } 637 | } 638 | } 639 | 640 | return binaries; 641 | } 642 | 643 | // copies everything _inside_ sourcePath to destinationPath 644 | bool recursiveCopy(const QString &sourcePath, const QString &destinationPath) 645 | { 646 | if (!QDir(sourcePath).exists()) 647 | return false; 648 | QDir().mkpath(destinationPath); 649 | 650 | LogNormal() << "copy:" << sourcePath << destinationPath; 651 | 652 | QStringList files = QDir(sourcePath).entryList(QStringList() << "*", QDir::Files | QDir::NoDotAndDotDot); 653 | foreach (QString file, files) { 654 | const QString fileSourcePath = sourcePath + "/" + file; 655 | const QString fileDestinationPath = destinationPath + "/" + file; 656 | copyFilePrintStatus(fileSourcePath, fileDestinationPath); 657 | } 658 | 659 | QStringList subdirs = QDir(sourcePath).entryList(QStringList() << "*", QDir::Dirs | QDir::NoDotAndDotDot); 660 | foreach (QString dir, subdirs) { 661 | recursiveCopy(sourcePath + "/" + dir, destinationPath + "/" + dir); 662 | } 663 | return true; 664 | } 665 | 666 | void recursiveCopyAndDeploy(const QString &appBundlePath, const QSet &rpaths, const QString &sourcePath, const QString &destinationPath) 667 | { 668 | QDir().mkpath(destinationPath); 669 | 670 | LogNormal() << "copy:" << sourcePath << destinationPath; 671 | const bool isDwarfPath = sourcePath.endsWith("DWARF"); 672 | 673 | QStringList files = QDir(sourcePath).entryList(QStringList() << QStringLiteral("*"), QDir::Files | QDir::NoDotAndDotDot); 674 | foreach (QString file, files) { 675 | const QString fileSourcePath = sourcePath + QLatin1Char('/') + file; 676 | 677 | if (file.endsWith("_debug.dylib")) { 678 | continue; // Skip debug versions 679 | } else if (!isDwarfPath && file.endsWith(QStringLiteral(".dylib"))) { 680 | // App store code signing rules forbids code binaries in Contents/Resources/, 681 | // which poses a problem for deploying mixed .qml/.dylib Qt Quick imports. 682 | // Solve this by placing the dylibs in Contents/PlugIns/quick, and then 683 | // creting a symlink to there from the Qt Quick import in Contents/Resources/. 684 | // 685 | // Example: 686 | // MyApp.app/Contents/Resources/qml/QtQuick/Controls/libqtquickcontrolsplugin.dylib -> 687 | // ../../../../PlugIns/quick/libqtquickcontrolsplugin.dylib 688 | // 689 | 690 | // The .dylib destination path: 691 | QString fileDestinationDir = appBundlePath + QStringLiteral("/Contents/PlugIns/quick/"); 692 | QDir().mkpath(fileDestinationDir); 693 | QString fileDestinationPath = fileDestinationDir + file; 694 | 695 | // The .dylib symlink destination path: 696 | QString linkDestinationPath = destinationPath + QLatin1Char('/') + file; 697 | 698 | // The (relative) link; with a correct number of "../"'s. 699 | QString linkPath = QStringLiteral("PlugIns/quick/") + file; 700 | int cdupCount = linkDestinationPath.count(QStringLiteral("/")) - appBundlePath.count(QStringLiteral("/")); 701 | for (int i = 0; i < cdupCount - 2; ++i) 702 | linkPath.prepend("../"); 703 | 704 | if (copyFilePrintStatus(fileSourcePath, fileDestinationPath)) { 705 | linkFilePrintStatus(linkPath, linkDestinationPath); 706 | 707 | runStrip(fileDestinationPath); 708 | bool useDebugLibs = false; 709 | bool useLoaderPath = false; 710 | QList frameworks = getQtFrameworks(fileDestinationPath, appBundlePath, rpaths, useDebugLibs); 711 | deployQtFrameworks(frameworks, appBundlePath, QStringList(fileDestinationPath), useDebugLibs, useLoaderPath); 712 | } 713 | } else { 714 | QString fileDestinationPath = destinationPath + QLatin1Char('/') + file; 715 | copyFilePrintStatus(fileSourcePath, fileDestinationPath); 716 | } 717 | } 718 | 719 | QStringList subdirs = QDir(sourcePath).entryList(QStringList() << QStringLiteral("*"), QDir::Dirs | QDir::NoDotAndDotDot); 720 | foreach (QString dir, subdirs) { 721 | recursiveCopyAndDeploy(appBundlePath, rpaths, sourcePath + QLatin1Char('/') + dir, destinationPath + QLatin1Char('/') + dir); 722 | } 723 | } 724 | 725 | QString copyDylib(const FrameworkInfo &framework, const QString path) 726 | { 727 | if (!QFile::exists(framework.sourceFilePath)) { 728 | LogError() << "no file at" << framework.sourceFilePath; 729 | return QString(); 730 | } 731 | 732 | // Construct destination paths. The full path typically looks like 733 | // MyApp.app/Contents/Frameworks/libfoo.dylib 734 | QString dylibDestinationDirectory = path + QLatin1Char('/') + framework.frameworkDestinationDirectory; 735 | QString dylibDestinationBinaryPath = dylibDestinationDirectory + QLatin1Char('/') + framework.binaryName; 736 | 737 | // Create destination directory 738 | if (!QDir().mkpath(dylibDestinationDirectory)) { 739 | LogError() << "could not create destination directory" << dylibDestinationDirectory; 740 | return QString(); 741 | } 742 | 743 | // Retrun if the dylib has aleardy been deployed 744 | if (QFileInfo(dylibDestinationBinaryPath).exists() && !alwaysOwerwriteEnabled) 745 | return dylibDestinationBinaryPath; 746 | 747 | // Copy dylib binary 748 | copyFilePrintStatus(framework.sourceFilePath, dylibDestinationBinaryPath); 749 | return dylibDestinationBinaryPath; 750 | } 751 | 752 | QString copyFramework(const FrameworkInfo &framework, const QString path) 753 | { 754 | if (!QFile::exists(framework.sourceFilePath)) { 755 | LogError() << "no file at" << framework.sourceFilePath; 756 | return QString(); 757 | } 758 | 759 | // Construct destination paths. The full path typically looks like 760 | // MyApp.app/Contents/Frameworks/Foo.framework/Versions/5/QtFoo 761 | QString frameworkDestinationDirectory = path + QLatin1Char('/') + framework.frameworkDestinationDirectory; 762 | QString frameworkBinaryDestinationDirectory = frameworkDestinationDirectory + QLatin1Char('/') + framework.binaryDirectory; 763 | QString frameworkDestinationBinaryPath = frameworkBinaryDestinationDirectory + QLatin1Char('/') + framework.binaryName; 764 | 765 | // Return if the framework has aleardy been deployed 766 | if (QDir(frameworkDestinationDirectory).exists() && !alwaysOwerwriteEnabled) 767 | return QString(); 768 | 769 | // Create destination directory 770 | if (!QDir().mkpath(frameworkBinaryDestinationDirectory)) { 771 | LogError() << "could not create destination directory" << frameworkBinaryDestinationDirectory; 772 | return QString(); 773 | } 774 | 775 | // Now copy the framework. Some parts should be left out (headers/, .prl files). 776 | // Some parts should be included (Resources/, symlink structure). We want this 777 | // function to make as few assumtions about the framework as possible while at 778 | // the same time producing a codesign-compatible framework. 779 | 780 | // Copy framework binary 781 | copyFilePrintStatus(framework.sourceFilePath, frameworkDestinationBinaryPath); 782 | 783 | // Copy Resouces/, Libraries/ and Helpers/ 784 | const QString resourcesSourcePath = framework.frameworkPath + "/Resources"; 785 | const QString resourcesDestianationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Resources"; 786 | recursiveCopy(resourcesSourcePath, resourcesDestianationPath); 787 | const QString librariesSourcePath = framework.frameworkPath + "/Libraries"; 788 | const QString librariesDestianationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Libraries"; 789 | bool createdLibraries = recursiveCopy(librariesSourcePath, librariesDestianationPath); 790 | const QString helpersSourcePath = framework.frameworkPath + "/Helpers"; 791 | const QString helpersDestianationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Helpers"; 792 | bool createdHelpers = recursiveCopy(helpersSourcePath, helpersDestianationPath); 793 | 794 | // Create symlink structure. Links at the framework root point to Versions/Current/ 795 | // which again points to the actual version: 796 | // QtFoo.framework/QtFoo -> Versions/Current/QtFoo 797 | // QtFoo.framework/Resources -> Versions/Current/Resources 798 | // QtFoo.framework/Versions/Current -> 5 799 | linkFilePrintStatus("Versions/Current/" + framework.binaryName, frameworkDestinationDirectory + "/" + framework.binaryName); 800 | linkFilePrintStatus("Versions/Current/Resources", frameworkDestinationDirectory + "/Resources"); 801 | if (createdLibraries) 802 | linkFilePrintStatus("Versions/Current/Libraries", frameworkDestinationDirectory + "/Libraries"); 803 | if (createdHelpers) 804 | linkFilePrintStatus("Versions/Current/Helpers", frameworkDestinationDirectory + "/Helpers"); 805 | linkFilePrintStatus(framework.version, frameworkDestinationDirectory + "/Versions/Current"); 806 | 807 | // Correct Info.plist location for frameworks produced by older versions of qmake 808 | // Contents/Info.plist should be Versions/5/Resources/Info.plist 809 | const QString legacyInfoPlistPath = framework.frameworkPath + "/Contents/Info.plist"; 810 | const QString correctInfoPlistPath = frameworkDestinationDirectory + "/Resources/Info.plist"; 811 | if (QFile(legacyInfoPlistPath).exists()) { 812 | copyFilePrintStatus(legacyInfoPlistPath, correctInfoPlistPath); 813 | patch_debugInInfoPlist(correctInfoPlistPath); 814 | } 815 | return frameworkDestinationBinaryPath; 816 | } 817 | 818 | void runInstallNameTool(QStringList options) 819 | { 820 | QProcess installNametool; 821 | installNametool.start("install_name_tool", options); 822 | installNametool.waitForFinished(); 823 | if (installNametool.exitCode() != 0) { 824 | LogError() << installNametool.readAllStandardError(); 825 | LogError() << installNametool.readAllStandardOutput(); 826 | } 827 | } 828 | 829 | void changeIdentification(const QString &id, const QString &binaryPath) 830 | { 831 | LogDebug() << "Using install_name_tool:"; 832 | LogDebug() << " change identification in" << binaryPath; 833 | LogDebug() << " to" << id; 834 | runInstallNameTool(QStringList() << "-id" << id << binaryPath); 835 | } 836 | 837 | void changeInstallName(const QString &bundlePath, const FrameworkInfo &framework, const QStringList &binaryPaths, bool useLoaderPath) 838 | { 839 | const QString absBundlePath = QFileInfo(bundlePath).absoluteFilePath(); 840 | foreach (const QString &binary, binaryPaths) { 841 | QString deployedInstallName; 842 | if (useLoaderPath) { 843 | deployedInstallName = QLatin1String("@loader_path/") 844 | + QFileInfo(binary).absoluteDir().relativeFilePath(absBundlePath + QLatin1Char('/') + framework.binaryDestinationDirectory + QLatin1Char('/') + framework.binaryName); 845 | } else { 846 | deployedInstallName = framework.deployedInstallName; 847 | } 848 | changeInstallName(framework.installName, deployedInstallName, binary); 849 | // Workaround for the case when the library ID name is a symlink, while the dependencies 850 | // specified using the canonical path to the library (QTBUG-56814) 851 | QString canonicalInstallName = QFileInfo(framework.installName).canonicalFilePath(); 852 | if (!canonicalInstallName.isEmpty() && canonicalInstallName != framework.installName) { 853 | changeInstallName(canonicalInstallName, deployedInstallName, binary); 854 | } 855 | } 856 | } 857 | 858 | void addRPath(const QString &rpath, const QString &binaryPath) 859 | { 860 | runInstallNameTool(QStringList() << "-add_rpath" << rpath << binaryPath); 861 | } 862 | 863 | void deployRPaths(const QString &bundlePath, const QSet &rpaths, const QString &binaryPath, bool useLoaderPath) 864 | { 865 | const QString absFrameworksPath = QFileInfo(bundlePath).absoluteFilePath() 866 | + QLatin1String("/Contents/Frameworks"); 867 | const QString relativeFrameworkPath = QFileInfo(binaryPath).absoluteDir().relativeFilePath(absFrameworksPath); 868 | const QString loaderPathToFrameworks = QLatin1String("@loader_path/") + relativeFrameworkPath; 869 | bool rpathToFrameworksFound = false; 870 | QStringList args; 871 | foreach (const QString &rpath, getBinaryRPaths(binaryPath, false)) { 872 | if (rpath == "@executable_path/../Frameworks" || 873 | rpath == loaderPathToFrameworks) { 874 | rpathToFrameworksFound = true; 875 | continue; 876 | } 877 | if (rpaths.contains(resolveDyldPrefix(rpath, binaryPath, binaryPath))) { 878 | args << "-delete_rpath" << rpath; 879 | } 880 | } 881 | if (!args.length()) { 882 | return; 883 | } 884 | if (!rpathToFrameworksFound) { 885 | if (!useLoaderPath) { 886 | args << "-add_rpath" << "@executable_path/../Frameworks"; 887 | } else { 888 | args << "-add_rpath" << loaderPathToFrameworks; 889 | } 890 | } 891 | LogDebug() << "Using install_name_tool:"; 892 | LogDebug() << " change rpaths in" << binaryPath; 893 | LogDebug() << " using" << args; 894 | runInstallNameTool(QStringList() << args << binaryPath); 895 | } 896 | 897 | void deployRPaths(const QString &bundlePath, const QSet &rpaths, const QStringList &binaryPaths, bool useLoaderPath) 898 | { 899 | foreach (const QString &binary, binaryPaths) { 900 | deployRPaths(bundlePath, rpaths, binary, useLoaderPath); 901 | } 902 | } 903 | 904 | void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath) 905 | { 906 | LogDebug() << "Using install_name_tool:"; 907 | LogDebug() << " in" << binaryPath; 908 | LogDebug() << " change reference" << oldName; 909 | LogDebug() << " to" << newName; 910 | runInstallNameTool(QStringList() << "-change" << oldName << newName << binaryPath); 911 | } 912 | 913 | void runStrip(const QString &binaryPath) 914 | { 915 | if (runStripEnabled == false) 916 | return; 917 | 918 | LogDebug() << "Using strip:"; 919 | LogDebug() << " stripped" << binaryPath; 920 | QProcess strip; 921 | strip.start("strip", QStringList() << "-x" << binaryPath); 922 | strip.waitForFinished(); 923 | if (strip.exitCode() != 0) { 924 | LogError() << strip.readAllStandardError(); 925 | LogError() << strip.readAllStandardOutput(); 926 | } 927 | } 928 | 929 | void stripAppBinary(const QString &bundlePath) 930 | { 931 | runStrip(findAppBinary(bundlePath)); 932 | } 933 | 934 | bool DeploymentInfo::containsModule(const QString &module, const QString &libInFix) const 935 | { 936 | // Check for framework first 937 | if (deployedFrameworks.contains(QLatin1String("Qt") + module + libInFix + 938 | QLatin1String(".framework"))) { 939 | return true; 940 | } 941 | // Check for dylib 942 | const QRegularExpression dylibRegExp(QLatin1String("libQt[0-9]+") + module + 943 | libInFix + QLatin1String(".[0-9]+.dylib")); 944 | return deployedFrameworks.filter(dylibRegExp).size() > 0; 945 | } 946 | 947 | /* 948 | Deploys the the listed frameworks listed into an app bundle. 949 | The frameworks are searched for dependencies, which are also deployed. 950 | (deploying Qt3Support will also deploy QtNetwork and QtSql for example.) 951 | Returns a DeploymentInfo structure containing the Qt path used and a 952 | a list of actually deployed frameworks. 953 | */ 954 | DeploymentInfo deployQtFrameworks(QList frameworks, 955 | const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs, 956 | bool useLoaderPath) 957 | { 958 | LogNormal(); 959 | LogNormal() << "Deploying Qt frameworks found inside:" << binaryPaths; 960 | QStringList copiedFrameworks; 961 | DeploymentInfo deploymentInfo; 962 | deploymentInfo.useLoaderPath = useLoaderPath; 963 | deploymentInfo.isFramework = bundlePath.contains(".framework"); 964 | deploymentInfo.isDebug = false; 965 | QSet rpathsUsed; 966 | 967 | while (frameworks.isEmpty() == false) { 968 | const FrameworkInfo framework = frameworks.takeFirst(); 969 | copiedFrameworks.append(framework.frameworkName); 970 | 971 | // If a single dependency has the _debug suffix, we treat that as 972 | // the whole deployment being a debug deployment, including deploying 973 | // the debug version of plugins. 974 | if (framework.isDebugLibrary()) 975 | deploymentInfo.isDebug = true; 976 | 977 | if (deploymentInfo.qtPath.isNull()) 978 | deploymentInfo.qtPath = customQtPath; 979 | 980 | if (framework.frameworkDirectory.startsWith(bundlePath)) { 981 | LogError() << framework.frameworkName << "already deployed, skipping."; 982 | continue; 983 | } 984 | 985 | if (!framework.rpathUsed.isEmpty()) 986 | rpathsUsed << framework.rpathUsed; 987 | 988 | // Copy the framework/dylib to the app bundle. 989 | const QString deployedBinaryPath = framework.isDylib ? copyDylib(framework, bundlePath) 990 | : copyFramework(framework, bundlePath); 991 | 992 | // Install_name_tool the new id into the binaries 993 | changeInstallName(bundlePath, framework, binaryPaths, useLoaderPath); 994 | 995 | // Skip the rest if already was deployed. 996 | if (deployedBinaryPath.isNull()) 997 | continue; 998 | 999 | runStrip(deployedBinaryPath); 1000 | 1001 | // Install_name_tool it a new id. 1002 | if (!framework.rpathUsed.length()) { 1003 | changeIdentification(framework.deployedInstallName, deployedBinaryPath); 1004 | } 1005 | 1006 | // Check for framework dependencies 1007 | QList dependencies = getQtFrameworks(deployedBinaryPath, bundlePath, rpathsUsed, useDebugLibs); 1008 | 1009 | foreach (FrameworkInfo dependency, dependencies) { 1010 | if (dependency.rpathUsed.isEmpty()) { 1011 | changeInstallName(bundlePath, dependency, QStringList() << deployedBinaryPath, useLoaderPath); 1012 | } else { 1013 | rpathsUsed << dependency.rpathUsed; 1014 | } 1015 | 1016 | // Deploy framework if necessary. 1017 | if (copiedFrameworks.contains(dependency.frameworkName) == false && frameworks.contains(dependency) == false) { 1018 | frameworks.append(dependency); 1019 | } 1020 | } 1021 | } 1022 | deploymentInfo.deployedFrameworks = copiedFrameworks; 1023 | deployRPaths(bundlePath, rpathsUsed, binaryPaths, useLoaderPath); 1024 | deploymentInfo.rpathsUsed += rpathsUsed; 1025 | return deploymentInfo; 1026 | } 1027 | 1028 | DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs) 1029 | { 1030 | ApplicationBundleInfo applicationBundle; 1031 | applicationBundle.path = appBundlePath; 1032 | applicationBundle.binaryPath = findAppBinary(appBundlePath); 1033 | applicationBundle.libraryPaths = findAppLibraries(appBundlePath); 1034 | QStringList allBinaryPaths = QStringList() << applicationBundle.binaryPath << applicationBundle.libraryPaths 1035 | << additionalExecutables; 1036 | QSet allLibraryPaths = getBinaryRPaths(applicationBundle.binaryPath, true); 1037 | allLibraryPaths.insert(QLibraryInfo::location(QLibraryInfo::LibrariesPath)); 1038 | QList frameworks = getQtFrameworksForPaths(allBinaryPaths, appBundlePath, allLibraryPaths, useDebugLibs); 1039 | if (frameworks.isEmpty() && !alwaysOwerwriteEnabled) { 1040 | LogWarning(); 1041 | LogWarning() << "Could not find any external Qt frameworks to deploy in" << appBundlePath; 1042 | LogWarning() << "Perhaps macdeployqt was already used on" << appBundlePath << "?"; 1043 | LogWarning() << "If so, you will need to rebuild" << appBundlePath << "before trying again."; 1044 | return DeploymentInfo(); 1045 | } else { 1046 | return deployQtFrameworks(frameworks, applicationBundle.path, allBinaryPaths, useDebugLibs, !additionalExecutables.isEmpty()); 1047 | } 1048 | } 1049 | 1050 | QString getLibInfix(const QStringList &deployedFrameworks) 1051 | { 1052 | QString libInfix; 1053 | foreach (const QString &framework, deployedFrameworks) { 1054 | if (framework.startsWith(QStringLiteral("QtCore")) && framework.endsWith(QStringLiteral(".framework"))) { 1055 | Q_ASSERT(framework.length() >= 16); 1056 | // 16 == "QtCore" + ".framework" 1057 | const int lengthOfLibInfix = framework.length() - 16; 1058 | if (lengthOfLibInfix) 1059 | libInfix = framework.mid(6, lengthOfLibInfix); 1060 | break; 1061 | } 1062 | } 1063 | return libInfix; 1064 | } 1065 | 1066 | void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pluginSourcePath, 1067 | const QString pluginDestinationPath, DeploymentInfo deploymentInfo, bool useDebugLibs) 1068 | { 1069 | LogNormal() << "Deploying plugins from" << pluginSourcePath; 1070 | 1071 | if (!pluginSourcePath.contains(deploymentInfo.pluginPath)) 1072 | return; 1073 | 1074 | // Plugin white list: 1075 | QStringList pluginList; 1076 | 1077 | const auto addPlugins = [&pluginSourcePath,&pluginList,useDebugLibs](const QString &subDirectory, 1078 | const std::function &predicate = std::function()) { 1079 | const QStringList libs = QDir(pluginSourcePath + QLatin1Char('/') + subDirectory) 1080 | .entryList({QStringLiteral("*.dylib")}); 1081 | for (const QString &lib : libs) { 1082 | if (lib.endsWith(QStringLiteral("_debug.dylib")) != useDebugLibs) 1083 | continue; 1084 | if (!predicate || predicate(lib)) 1085 | pluginList.append(subDirectory + QLatin1Char('/') + lib); 1086 | } 1087 | }; 1088 | 1089 | // Platform plugin: 1090 | addPlugins(QStringLiteral("platforms"), [](const QString &lib) { 1091 | // Ignore minimal and offscreen platform plugins 1092 | if (!lib.contains(QStringLiteral("cocoa"))) 1093 | return false; 1094 | return true; 1095 | }); 1096 | 1097 | // Cocoa print support 1098 | addPlugins(QStringLiteral("printsupport")); 1099 | 1100 | // Styles 1101 | addPlugins(QStringLiteral("styles")); 1102 | 1103 | // Check if Qt was configured with -libinfix 1104 | const QString libInfix = getLibInfix(deploymentInfo.deployedFrameworks); 1105 | 1106 | // Network 1107 | if (deploymentInfo.containsModule("Network", libInfix)) 1108 | addPlugins(QStringLiteral("bearer")); 1109 | 1110 | // All image formats (svg if QtSvg is used) 1111 | const bool usesSvg = deploymentInfo.containsModule("Svg", libInfix); 1112 | addPlugins(QStringLiteral("imageformats"), [usesSvg](const QString &lib) { 1113 | if (lib.contains(QStringLiteral("qsvg")) && !usesSvg) 1114 | return false; 1115 | return true; 1116 | }); 1117 | 1118 | addPlugins(QStringLiteral("iconengines")); 1119 | 1120 | // Platforminputcontext plugins if QtGui is in use 1121 | if (deploymentInfo.containsModule("Gui", libInfix)) { 1122 | addPlugins(QStringLiteral("platforminputcontexts"), [&addPlugins](const QString &lib) { 1123 | // Deploy the virtual keyboard plugins if we have deployed virtualkeyboard 1124 | if (lib.startsWith(QStringLiteral("libqtvirtualkeyboard"))) 1125 | addPlugins(QStringLiteral("virtualkeyboard")); 1126 | return true; 1127 | }); 1128 | } 1129 | 1130 | // Sql plugins if QtSql is in use 1131 | if (deploymentInfo.containsModule("Sql", libInfix)) { 1132 | addPlugins(QStringLiteral("sqldrivers"), [](const QString &lib) { 1133 | if (lib.startsWith(QStringLiteral("libqsqlodbc")) || lib.startsWith(QStringLiteral("libqsqlpsql"))) { 1134 | LogWarning() << "Plugin" << lib << "uses private API and is not Mac App store compliant."; 1135 | if (appstoreCompliant) { 1136 | LogWarning() << "Skip plugin" << lib; 1137 | return false; 1138 | } 1139 | } 1140 | return true; 1141 | }); 1142 | } 1143 | 1144 | // WebView plugins if QtWebView is in use 1145 | if (deploymentInfo.containsModule("WebView", libInfix)) { 1146 | addPlugins(QStringLiteral("webview"), [](const QString &lib) { 1147 | if (lib.startsWith(QStringLiteral("libqtwebview_webengine"))) { 1148 | LogWarning() << "Plugin" << lib << "uses QtWebEngine and is not Mac App store compliant."; 1149 | if (appstoreCompliant) { 1150 | LogWarning() << "Skip plugin" << lib; 1151 | return false; 1152 | } 1153 | } 1154 | return true; 1155 | }); 1156 | } 1157 | 1158 | static const std::map> map { 1159 | {QStringLiteral("Multimedia"), {QStringLiteral("mediaservice"), QStringLiteral("audio")}}, 1160 | {QStringLiteral("3DRender"), {QStringLiteral("sceneparsers"), QStringLiteral("geometryloaders")}}, 1161 | {QStringLiteral("3DQuickRender"), {QStringLiteral("renderplugins")}}, 1162 | {QStringLiteral("Positioning"), {QStringLiteral("position")}}, 1163 | {QStringLiteral("Location"), {QStringLiteral("geoservices")}}, 1164 | {QStringLiteral("TextToSpeech"), {QStringLiteral("texttospeech")}} 1165 | }; 1166 | 1167 | for (const auto &it : map) { 1168 | if (deploymentInfo.containsModule(it.first, libInfix)) { 1169 | for (const auto &pluginType : it.second) { 1170 | addPlugins(pluginType); 1171 | } 1172 | } 1173 | } 1174 | 1175 | foreach (const QString &plugin, pluginList) { 1176 | QString sourcePath = pluginSourcePath + "/" + plugin; 1177 | const QString destinationPath = pluginDestinationPath + "/" + plugin; 1178 | QDir dir; 1179 | dir.mkpath(QFileInfo(destinationPath).path()); 1180 | 1181 | if (copyFilePrintStatus(sourcePath, destinationPath)) { 1182 | runStrip(destinationPath); 1183 | QList frameworks = getQtFrameworks(destinationPath, appBundleInfo.path, deploymentInfo.rpathsUsed, useDebugLibs); 1184 | deployQtFrameworks(frameworks, appBundleInfo.path, QStringList() << destinationPath, useDebugLibs, deploymentInfo.useLoaderPath); 1185 | } 1186 | } 1187 | } 1188 | 1189 | void createQtConf(const QString &appBundlePath) 1190 | { 1191 | // Set Plugins and imports paths. These are relative to App.app/Contents. 1192 | QByteArray contents = "[Paths]\n" 1193 | "Plugins = PlugIns\n" 1194 | "Imports = Resources/qml\n" 1195 | "Qml2Imports = Resources/qml\n"; 1196 | 1197 | QString filePath = appBundlePath + "/Contents/Resources/"; 1198 | QString fileName = filePath + "qt.conf"; 1199 | 1200 | QDir().mkpath(filePath); 1201 | 1202 | QFile qtconf(fileName); 1203 | if (qtconf.exists() && !alwaysOwerwriteEnabled) { 1204 | LogWarning(); 1205 | LogWarning() << fileName << "already exists, will not overwrite."; 1206 | LogWarning() << "To make sure the plugins are loaded from the correct location,"; 1207 | LogWarning() << "please make sure qt.conf contains the following lines:"; 1208 | LogWarning() << "[Paths]"; 1209 | LogWarning() << " Plugins = PlugIns"; 1210 | return; 1211 | } 1212 | 1213 | qtconf.open(QIODevice::WriteOnly); 1214 | if (qtconf.write(contents) != -1) { 1215 | LogNormal() << "Created configuration file:" << fileName; 1216 | LogNormal() << "This file sets the plugin search path to" << appBundlePath + "/Contents/PlugIns"; 1217 | } 1218 | } 1219 | 1220 | void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs) 1221 | { 1222 | ApplicationBundleInfo applicationBundle; 1223 | applicationBundle.path = appBundlePath; 1224 | applicationBundle.binaryPath = findAppBinary(appBundlePath); 1225 | 1226 | const QString pluginDestinationPath = appBundlePath + "/" + "Contents/PlugIns"; 1227 | deployPlugins(applicationBundle, deploymentInfo.pluginPath, pluginDestinationPath, deploymentInfo, useDebugLibs); 1228 | } 1229 | 1230 | void deployQmlImport(const QString &appBundlePath, const QSet &rpaths, const QString &importSourcePath, const QString &importName) 1231 | { 1232 | QString importDestinationPath = appBundlePath + "/Contents/Resources/qml/" + importName; 1233 | 1234 | // Skip already deployed imports. This can happen in cases like "QtQuick.Controls.Styles", 1235 | // where deploying QtQuick.Controls will also deploy the "Styles" sub-import. 1236 | if (QDir().exists(importDestinationPath)) 1237 | return; 1238 | 1239 | recursiveCopyAndDeploy(appBundlePath, rpaths, importSourcePath, importDestinationPath); 1240 | } 1241 | 1242 | static bool importLessThan(const QVariant &v1, const QVariant &v2) 1243 | { 1244 | QVariantMap import1 = v1.toMap(); 1245 | QVariantMap import2 = v2.toMap(); 1246 | QString path1 = import1["path"].toString(); 1247 | QString path2 = import2["path"].toString(); 1248 | return path1 < path2; 1249 | } 1250 | 1251 | // Scan qml files in qmldirs for import statements, deploy used imports from Qml2ImportsPath to Contents/Resources/qml. 1252 | bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths) 1253 | { 1254 | LogNormal() << ""; 1255 | LogNormal() << "Deploying QML imports "; 1256 | LogNormal() << "Application QML file path(s) is" << qmlDirs; 1257 | LogNormal() << "QML module search path(s) is" << qmlImportPaths; 1258 | 1259 | // Use qmlimportscanner from QLibraryInfo::BinariesPath 1260 | QString qmlImportScannerPath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlimportscanner"); 1261 | 1262 | // Fallback: Look relative to the macdeployqt binary 1263 | if (!QFile(qmlImportScannerPath).exists()) 1264 | qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner"; 1265 | 1266 | // Verify that we found a qmlimportscanner binary 1267 | if (!QFile(qmlImportScannerPath).exists()) { 1268 | LogError() << "qmlimportscanner not found at" << qmlImportScannerPath; 1269 | LogError() << "Rebuild qtdeclarative/tools/qmlimportscanner"; 1270 | return false; 1271 | } 1272 | 1273 | // build argument list for qmlimportsanner: "-rootPath foo/ -rootPath bar/ -importPath path/to/qt/qml" 1274 | // ("rootPath" points to a directory containing app qml, "importPath" is where the Qt imports are installed) 1275 | QStringList argumentList; 1276 | foreach (const QString &qmlDir, qmlDirs) { 1277 | argumentList.append("-rootPath"); 1278 | argumentList.append(qmlDir); 1279 | } 1280 | for (const QString &importPath : qmlImportPaths) 1281 | argumentList << "-importPath" << importPath; 1282 | QString qmlImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); 1283 | argumentList.append( "-importPath"); 1284 | argumentList.append(qmlImportsPath); 1285 | 1286 | // run qmlimportscanner 1287 | QProcess qmlImportScanner; 1288 | qmlImportScanner.start(qmlImportScannerPath, argumentList); 1289 | if (!qmlImportScanner.waitForStarted()) { 1290 | LogError() << "Could not start qmlimpoortscanner. Process error is" << qmlImportScanner.errorString(); 1291 | return false; 1292 | } 1293 | qmlImportScanner.waitForFinished(); 1294 | 1295 | // log qmlimportscanner errors 1296 | qmlImportScanner.setReadChannel(QProcess::StandardError); 1297 | QByteArray errors = qmlImportScanner.readAll(); 1298 | if (!errors.isEmpty()) { 1299 | LogWarning() << "QML file parse error (deployment will continue):"; 1300 | LogWarning() << errors; 1301 | } 1302 | 1303 | // parse qmlimportscanner json 1304 | qmlImportScanner.setReadChannel(QProcess::StandardOutput); 1305 | QByteArray json = qmlImportScanner.readAll(); 1306 | QJsonDocument doc = QJsonDocument::fromJson(json); 1307 | if (!doc.isArray()) { 1308 | LogError() << "qmlimportscanner output error. Expected json array, got:"; 1309 | LogError() << json; 1310 | return false; 1311 | } 1312 | 1313 | // sort imports to deploy a module before its sub-modules (otherwise 1314 | // deployQmlImports can consider the module deployed if it has already 1315 | // deployed one of its sub-module) 1316 | QVariantList array = doc.array().toVariantList(); 1317 | std::sort(array.begin(), array.end(), importLessThan); 1318 | 1319 | // deploy each import 1320 | foreach (const QVariant &importValue, array) { 1321 | QVariantMap import = importValue.toMap(); 1322 | QString name = import["name"].toString(); 1323 | QString path = import["path"].toString(); 1324 | QString type = import["type"].toString(); 1325 | 1326 | LogNormal() << "Deploying QML import" << name; 1327 | 1328 | // Skip imports with missing info - path will be empty if the import is not found. 1329 | if (name.isEmpty() || path.isEmpty()) { 1330 | LogNormal() << " Skip import: name or path is empty"; 1331 | LogNormal() << ""; 1332 | continue; 1333 | } 1334 | 1335 | // Deploy module imports only, skip directory (local/remote) and js imports. These 1336 | // should be deployed as a part of the application build. 1337 | if (type != QStringLiteral("module")) { 1338 | LogNormal() << " Skip non-module import"; 1339 | LogNormal() << ""; 1340 | continue; 1341 | } 1342 | 1343 | // Create the destination path from the name 1344 | // and version (grabbed from the source path) 1345 | // ### let qmlimportscanner provide this. 1346 | name.replace(QLatin1Char('.'), QLatin1Char('/')); 1347 | int secondTolast = path.length() - 2; 1348 | QString version = path.mid(secondTolast); 1349 | if (version.startsWith(QLatin1Char('.'))) 1350 | name.append(version); 1351 | 1352 | deployQmlImport(appBundlePath, deploymentInfo.rpathsUsed, path, name); 1353 | LogNormal() << ""; 1354 | } 1355 | return true; 1356 | } 1357 | 1358 | void changeQtFrameworks(const QList frameworks, const QStringList &binaryPaths, const QString &absoluteQtPath) 1359 | { 1360 | LogNormal() << "Changing" << binaryPaths << "to link against"; 1361 | LogNormal() << "Qt in" << absoluteQtPath; 1362 | QString finalQtPath = absoluteQtPath; 1363 | 1364 | if (!absoluteQtPath.startsWith("/Library/Frameworks")) 1365 | finalQtPath += "/lib/"; 1366 | 1367 | foreach (FrameworkInfo framework, frameworks) { 1368 | const QString oldBinaryId = framework.installName; 1369 | const QString newBinaryId = finalQtPath + framework.frameworkName + framework.binaryPath; 1370 | foreach (const QString &binary, binaryPaths) 1371 | changeInstallName(oldBinaryId, newBinaryId, binary); 1372 | } 1373 | } 1374 | 1375 | void changeQtFrameworks(const QString appPath, const QString &qtPath, bool useDebugLibs) 1376 | { 1377 | const QString appBinaryPath = findAppBinary(appPath); 1378 | const QStringList libraryPaths = findAppLibraries(appPath); 1379 | const QList frameworks = getQtFrameworksForPaths(QStringList() << appBinaryPath << libraryPaths, appPath, getBinaryRPaths(appBinaryPath, true), useDebugLibs); 1380 | if (frameworks.isEmpty()) { 1381 | LogWarning(); 1382 | LogWarning() << "Could not find any _external_ Qt frameworks to change in" << appPath; 1383 | return; 1384 | } else { 1385 | const QString absoluteQtPath = QDir(qtPath).absolutePath(); 1386 | changeQtFrameworks(frameworks, QStringList() << appBinaryPath << libraryPaths, absoluteQtPath); 1387 | } 1388 | } 1389 | 1390 | void codesignFile(const QString &identity, const QString &filePath) 1391 | { 1392 | if (!runCodesign) 1393 | return; 1394 | 1395 | QString codeSignLogMessage = "codesign"; 1396 | if (hardenedRuntime) 1397 | codeSignLogMessage += ", enable hardened runtime"; 1398 | if (secureTimestamp) 1399 | codeSignLogMessage += ", include secure timestamp"; 1400 | LogNormal() << codeSignLogMessage << filePath; 1401 | 1402 | QStringList codeSignOptions = { "--preserve-metadata=identifier,entitlements", "--force", "-s", 1403 | identity, filePath }; 1404 | if (hardenedRuntime) 1405 | codeSignOptions << "-o" << "runtime"; 1406 | 1407 | if (secureTimestamp) 1408 | codeSignOptions << "--timestamp"; 1409 | 1410 | if (!extraEntitlements.isEmpty()) 1411 | codeSignOptions << "--entitlements" << extraEntitlements; 1412 | 1413 | QProcess codesign; 1414 | codesign.start("codesign", codeSignOptions); 1415 | codesign.waitForFinished(-1); 1416 | 1417 | QByteArray err = codesign.readAllStandardError(); 1418 | if (codesign.exitCode() > 0) { 1419 | LogError() << "Codesign signing error:"; 1420 | LogError() << err; 1421 | } else if (!err.isEmpty()) { 1422 | LogDebug() << err; 1423 | } 1424 | } 1425 | 1426 | QSet codesignBundle(const QString &identity, 1427 | const QString &appBundlePath, 1428 | QList additionalBinariesContainingRpaths) 1429 | { 1430 | // Code sign all binaries in the app bundle. This needs to 1431 | // be done inside-out, e.g sign framework dependencies 1432 | // before the main app binary. The codesign tool itself has 1433 | // a "--deep" option to do this, but usage when signing is 1434 | // not recommended: "Signing with --deep is for emergency 1435 | // repairs and temporary adjustments only." 1436 | 1437 | LogNormal() << ""; 1438 | LogNormal() << "Signing" << appBundlePath << "with identity" << identity; 1439 | 1440 | QStack pendingBinaries; 1441 | QSet pendingBinariesSet; 1442 | QSet signedBinaries; 1443 | 1444 | // Create the root code-binary set. This set consists of the application 1445 | // executable(s) and the plugins. 1446 | QString appBundleAbsolutePath = QFileInfo(appBundlePath).absoluteFilePath(); 1447 | QString rootBinariesPath = appBundleAbsolutePath + "/Contents/MacOS/"; 1448 | QStringList foundRootBinaries = QDir(rootBinariesPath).entryList(QStringList() << "*", QDir::Files); 1449 | foreach (const QString &binary, foundRootBinaries) { 1450 | QString binaryPath = rootBinariesPath + binary; 1451 | pendingBinaries.push(binaryPath); 1452 | pendingBinariesSet.insert(binaryPath); 1453 | additionalBinariesContainingRpaths.append(binaryPath); 1454 | } 1455 | 1456 | bool getAbsoltuePath = true; 1457 | QStringList foundPluginBinaries = findAppBundleFiles(appBundlePath + "/Contents/PlugIns/", getAbsoltuePath); 1458 | foreach (const QString &binary, foundPluginBinaries) { 1459 | pendingBinaries.push(binary); 1460 | pendingBinariesSet.insert(binary); 1461 | } 1462 | 1463 | // Add frameworks for processing. 1464 | QStringList frameworkPaths = findAppFrameworkPaths(appBundlePath); 1465 | foreach (const QString &frameworkPath, frameworkPaths) { 1466 | 1467 | // Prioritise first to sign any additional inner bundles found in the Helpers folder (e.g 1468 | // used by QtWebEngine). 1469 | QDirIterator helpersIterator(frameworkPath, QStringList() << QString::fromLatin1("Helpers"), QDir::Dirs | QDir::NoSymLinks, QDirIterator::Subdirectories); 1470 | while (helpersIterator.hasNext()) { 1471 | helpersIterator.next(); 1472 | QString helpersPath = helpersIterator.filePath(); 1473 | QStringList innerBundleNames = QDir(helpersPath).entryList(QStringList() << "*.app", QDir::Dirs); 1474 | foreach (const QString &innerBundleName, innerBundleNames) 1475 | signedBinaries += codesignBundle(identity, 1476 | helpersPath + "/" + innerBundleName, 1477 | additionalBinariesContainingRpaths); 1478 | } 1479 | 1480 | // Also make sure to sign any libraries that will not be found by otool because they 1481 | // are not linked and won't be seen as a dependency. 1482 | QDirIterator librariesIterator(frameworkPath, QStringList() << QString::fromLatin1("Libraries"), QDir::Dirs | QDir::NoSymLinks, QDirIterator::Subdirectories); 1483 | while (librariesIterator.hasNext()) { 1484 | librariesIterator.next(); 1485 | QString librariesPath = librariesIterator.filePath(); 1486 | QStringList bundleFiles = findAppBundleFiles(librariesPath, getAbsoltuePath); 1487 | foreach (const QString &binary, bundleFiles) { 1488 | pendingBinaries.push(binary); 1489 | pendingBinariesSet.insert(binary); 1490 | } 1491 | } 1492 | } 1493 | 1494 | // Sign all binaries; use otool to find and sign dependencies first. 1495 | while (!pendingBinaries.isEmpty()) { 1496 | QString binary = pendingBinaries.pop(); 1497 | if (signedBinaries.contains(binary)) 1498 | continue; 1499 | 1500 | // Check if there are unsigned dependencies, sign these first. 1501 | QStringList dependencies = 1502 | getBinaryDependencies(rootBinariesPath, binary, additionalBinariesContainingRpaths).toSet() 1503 | .subtract(signedBinaries) 1504 | .subtract(pendingBinariesSet) 1505 | .toList(); 1506 | 1507 | if (!dependencies.isEmpty()) { 1508 | pendingBinaries.push(binary); 1509 | pendingBinariesSet.insert(binary); 1510 | int dependenciesSkipped = 0; 1511 | foreach (const QString &dependency, dependencies) { 1512 | // Skip dependencies that are outside the current app bundle, because this might 1513 | // cause a codesign error if the current bundle is part of the dependency (e.g. 1514 | // a bundle is part of a framework helper, and depends on that framework). 1515 | // The dependencies will be taken care of after the current bundle is signed. 1516 | if (!dependency.startsWith(appBundleAbsolutePath)) { 1517 | ++dependenciesSkipped; 1518 | LogNormal() << "Skipping outside dependency: " << dependency; 1519 | continue; 1520 | } 1521 | pendingBinaries.push(dependency); 1522 | pendingBinariesSet.insert(dependency); 1523 | } 1524 | 1525 | // If all dependencies were skipped, make sure the binary is actually signed, instead 1526 | // of going into an infinite loop. 1527 | if (dependenciesSkipped == dependencies.size()) { 1528 | pendingBinaries.pop(); 1529 | } else { 1530 | continue; 1531 | } 1532 | } 1533 | 1534 | // Look for an entitlements file in the bundle to include when signing 1535 | extraEntitlements = findEntitlementsFile(appBundleAbsolutePath + "/Contents/Resources/"); 1536 | 1537 | // All dependencies are signed, now sign this binary. 1538 | codesignFile(identity, binary); 1539 | signedBinaries.insert(binary); 1540 | pendingBinariesSet.remove(binary); 1541 | } 1542 | 1543 | LogNormal() << "Finished codesigning " << appBundlePath << "with identity" << identity; 1544 | 1545 | // Verify code signature 1546 | QProcess codesign; 1547 | codesign.start("codesign", QStringList() << "--deep" << "-v" << appBundlePath); 1548 | codesign.waitForFinished(-1); 1549 | QByteArray err = codesign.readAllStandardError(); 1550 | if (codesign.exitCode() > 0) { 1551 | LogError() << "codesign verification error:"; 1552 | LogError() << err; 1553 | } else if (!err.isEmpty()) { 1554 | LogDebug() << err; 1555 | } 1556 | 1557 | return signedBinaries; 1558 | } 1559 | 1560 | void codesign(const QString &identity, const QString &appBundlePath) { 1561 | codesignBundle(identity, appBundlePath, QList()); 1562 | } 1563 | 1564 | void createDiskImage(const QString &appBundlePath, const QString &filesystemType) 1565 | { 1566 | QString appBaseName = appBundlePath; 1567 | appBaseName.chop(4); // remove ".app" from end 1568 | 1569 | QString dmgName = appBaseName + ".dmg"; 1570 | 1571 | QFile dmg(dmgName); 1572 | 1573 | if (dmg.exists() && alwaysOwerwriteEnabled) 1574 | dmg.remove(); 1575 | 1576 | if (dmg.exists()) { 1577 | LogNormal() << "Disk image already exists, skipping .dmg creation for" << dmg.fileName(); 1578 | } else { 1579 | LogNormal() << "Creating disk image (.dmg) for" << appBundlePath; 1580 | } 1581 | 1582 | LogNormal() << "Image will use" << filesystemType; 1583 | 1584 | // More dmg options can be found in the hdiutil man page. 1585 | QStringList options = QStringList() 1586 | << "create" << dmgName 1587 | << "-srcfolder" << appBundlePath 1588 | << "-format" << "UDZO" 1589 | << "-fs" << filesystemType 1590 | << "-volname" << appBaseName; 1591 | 1592 | QProcess hdutil; 1593 | hdutil.start("hdiutil", options); 1594 | hdutil.waitForFinished(-1); 1595 | if (hdutil.exitCode() != 0) { 1596 | LogError() << "Bundle creation error:" << hdutil.readAllStandardError(); 1597 | } 1598 | } 1599 | 1600 | void fixupFramework(const QString &frameworkName) 1601 | { 1602 | // Expected framework name looks like "Foo.framework" 1603 | QStringList parts = frameworkName.split("."); 1604 | if (parts.count() < 2) { 1605 | LogError() << "fixupFramework: Unexpected framework name" << frameworkName; 1606 | return; 1607 | } 1608 | 1609 | // Assume framework binary path is Foo.framework/Foo 1610 | QString frameworkBinary = frameworkName + QStringLiteral("/") + parts[0]; 1611 | 1612 | // Xcode expects to find Foo.framework/Versions/A when code 1613 | // signing, while qmake typically generates numeric versions. 1614 | // Create symlink to the actual version in the framework. 1615 | linkFilePrintStatus("Current", frameworkName + "/Versions/A"); 1616 | 1617 | // Set up @rpath structure. 1618 | changeIdentification("@rpath/" + frameworkBinary, frameworkBinary); 1619 | addRPath("@loader_path/../../Contents/Frameworks/", frameworkBinary); 1620 | } 1621 | -------------------------------------------------------------------------------- /macdeployqt_src/shared.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the tools applications of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** GNU General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU 19 | ** General Public License version 3 as published by the Free Software 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 21 | ** included in the packaging of this file. Please review the following 22 | ** information to ensure the GNU General Public License requirements will 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 24 | ** 25 | ** $QT_END_LICENSE$ 26 | ** 27 | ****************************************************************************/ 28 | #ifndef MAC_DEPLOMYMENT_SHARED_H 29 | #define MAC_DEPLOMYMENT_SHARED_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | extern int logLevel; 38 | #define LogError() if (logLevel < 0) {} else qDebug() << "ERROR:" 39 | #define LogWarning() if (logLevel < 1) {} else qDebug() << "WARNING:" 40 | #define LogNormal() if (logLevel < 2) {} else qDebug() << "Log:" 41 | #define LogDebug() if (logLevel < 3) {} else qDebug() << "Log:" 42 | 43 | extern bool runStripEnabled; 44 | 45 | class FrameworkInfo 46 | { 47 | public: 48 | bool isDylib; 49 | QString frameworkDirectory; 50 | QString frameworkName; 51 | QString frameworkPath; 52 | QString binaryDirectory; 53 | QString binaryName; 54 | QString binaryPath; 55 | QString rpathUsed; 56 | QString version; 57 | QString installName; 58 | QString deployedInstallName; 59 | QString sourceFilePath; 60 | QString frameworkDestinationDirectory; 61 | QString binaryDestinationDirectory; 62 | 63 | bool isDebugLibrary() const 64 | { 65 | return binaryName.contains(QLatin1String("_debug")); 66 | } 67 | }; 68 | 69 | class DylibInfo 70 | { 71 | public: 72 | QString binaryPath; 73 | QVersionNumber currentVersion; 74 | QVersionNumber compatibilityVersion; 75 | }; 76 | 77 | class OtoolInfo 78 | { 79 | public: 80 | QString installName; 81 | QString binaryPath; 82 | QVersionNumber currentVersion; 83 | QVersionNumber compatibilityVersion; 84 | QList dependencies; 85 | }; 86 | 87 | bool operator==(const FrameworkInfo &a, const FrameworkInfo &b); 88 | QDebug operator<<(QDebug debug, const FrameworkInfo &info); 89 | 90 | class ApplicationBundleInfo 91 | { 92 | public: 93 | QString path; 94 | QString binaryPath; 95 | QStringList libraryPaths; 96 | }; 97 | 98 | class DeploymentInfo 99 | { 100 | public: 101 | QString qtPath; 102 | QString pluginPath; 103 | QStringList deployedFrameworks; 104 | QSet rpathsUsed; 105 | bool useLoaderPath; 106 | bool isFramework; 107 | bool isDebug; 108 | 109 | bool containsModule(const QString &module, const QString &libInFix) const; 110 | }; 111 | 112 | inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info); 113 | 114 | void changeQtFrameworks(const QString appPath, const QString &qtPath, bool useDebugLibs); 115 | void changeQtFrameworks(const QList frameworks, const QStringList &binaryPaths, const QString &qtPath); 116 | 117 | OtoolInfo findDependencyInfo(const QString &binaryPath); 118 | FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundlePath, const QSet &rpaths, bool useDebugLibs); 119 | QString findAppBinary(const QString &appBundlePath); 120 | QList getQtFrameworks(const QString &path, const QString &appBundlePath, const QSet &rpaths, bool useDebugLibs); 121 | QList getQtFrameworks(const QStringList &otoolLines, const QString &appBundlePath, const QSet &rpaths, bool useDebugLibs); 122 | QString copyFramework(const FrameworkInfo &framework, const QString path); 123 | DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs); 124 | DeploymentInfo deployQtFrameworks(QList frameworks,const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs, bool useLoaderPath); 125 | void createQtConf(const QString &appBundlePath); 126 | void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs); 127 | bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths); 128 | void changeIdentification(const QString &id, const QString &binaryPath); 129 | void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath); 130 | void runStrip(const QString &binaryPath); 131 | void stripAppBinary(const QString &bundlePath); 132 | QString findAppBinary(const QString &appBundlePath); 133 | QStringList findAppFrameworkNames(const QString &appBundlePath); 134 | QStringList findAppFrameworkPaths(const QString &appBundlePath); 135 | void codesignFile(const QString &identity, const QString &filePath); 136 | QSet codesignBundle(const QString &identity, 137 | const QString &appBundlePath, 138 | QList additionalBinariesContainingRpaths); 139 | void codesign(const QString &identity, const QString &appBundlePath); 140 | void createDiskImage(const QString &appBundlePath, const QString &filesystemType); 141 | void fixupFramework(const QString &appBundlePath); 142 | 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /screens/qt_configurations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crystalidea/macdeployqt-universal/6f4e11da4a3675c1696d83a6c08ee9d7a2661461/screens/qt_configurations.png -------------------------------------------------------------------------------- /screens/qt_kits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crystalidea/macdeployqt-universal/6f4e11da4a3675c1696d83a6c08ee9d7a2661461/screens/qt_kits.png -------------------------------------------------------------------------------- /screens/qt_versions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crystalidea/macdeployqt-universal/6f4e11da4a3675c1696d83a6c08ee9d7a2661461/screens/qt_versions.png --------------------------------------------------------------------------------