From 8bd4e25b7fdd4411a013b90be956b4bb30227e81 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Sun, 17 May 2020 22:22:25 -0700 Subject: [PATCH] Uses real app icon for AltBackup icon --- AltStore/Managing Apps/AppManager.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index 27140b45..cb0da7e0 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -1056,6 +1056,26 @@ private extension AppManager exportedUTIs.append(installedAppUTI) infoDictionary[Bundle.Info.exportedUTIs] = exportedUTIs + if let cachedApp = ALTApplication(fileURL: app.fileURL), let icon = cachedApp.icon?.resizing(to: CGSize(width: 180, height: 180)) + { + let iconFileURL = unzippedAppBundleURL.appendingPathComponent("AppIcon.png") + + if let iconData = icon.pngData() + { + do + { + try iconData.write(to: iconFileURL, options: .atomic) + + let bundleIcons = ["CFBundlePrimaryIcon": ["CFBundleIconFiles": [iconFileURL.lastPathComponent]]] + infoDictionary["CFBundleIcons"] = bundleIcons + } + catch + { + print("Failed to write app icon data.", error) + } + } + } + try (infoDictionary as NSDictionary).write(to: unzippedAppBundle.infoPlistURL) }