Skip to content

Commit 5984048

Browse files
committed
macdeployqt: Make sure the app binary is signed after any other binarie
This avoids a codesign verification error that may appear as "nested code is modified or invalid". This commit was originally created by https://github.com/tsteven4 #125 Pick-to: 6.5 6.8 6.10 Change-Id: Ifa0b4ed9da1d7b36cb54f9d2fa6aee48c1fe519c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
1 parent c9dc012 commit 5984048

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/tools/macdeployqt/shared/shared.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,17 @@ QSet<QString> codesignBundle(const QString &identity,
14471447
QString appBundleAbsolutePath = QFileInfo(appBundlePath).absoluteFilePath();
14481448
QString rootBinariesPath = appBundleAbsolutePath + "/Contents/MacOS/";
14491449
QStringList foundRootBinaries = QDir(rootBinariesPath).entryList(QStringList() << "*", QDir::Files);
1450+
1451+
// The app binary must be signed last.
1452+
QString appBinary = findAppBinary(appBundleAbsolutePath);
1453+
QString appBinaryName = QFileInfo(appBinary).fileName();
1454+
if (int appBinaryIdx = foundRootBinaries.indexOf(appBinaryName); appBinaryIdx > 0) {
1455+
foundRootBinaries.swapItemsAt(0, appBinaryIdx);
1456+
LogDebug() << "swapped appBinary to start of list";
1457+
}
1458+
LogDebug() << "App binary is" << appBinaryName;
1459+
LogDebug() << "Binaries in" << rootBinariesPath << "are" << foundRootBinaries;
1460+
14501461
for (const QString &binary : foundRootBinaries) {
14511462
QString binaryPath = rootBinariesPath + binary;
14521463
pendingBinaries.push(binaryPath);

0 commit comments

Comments
 (0)