mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Adds ability to change sideloaded app icons
This commit is contained in:
@@ -114,4 +114,6 @@ class InstallAppOperationContext: AppOperationContext
|
||||
private var installedAppContext: NSManagedObjectContext?
|
||||
|
||||
var beginInstallationHandler: ((InstalledApp) -> Void)?
|
||||
|
||||
var alternateIconURL: URL?
|
||||
}
|
||||
|
||||
@@ -191,6 +191,22 @@ private extension ResignAppOperation
|
||||
}
|
||||
}
|
||||
|
||||
let iconScale = Int(UIScreen.main.scale)
|
||||
|
||||
if let alternateIconURL = self.context.alternateIconURL,
|
||||
case let data = try Data(contentsOf: alternateIconURL),
|
||||
let image = UIImage(data: data),
|
||||
let icon = image.resizing(toFill: CGSize(width: 60 * iconScale, height: 60 * iconScale)),
|
||||
let iconData = icon.pngData()
|
||||
{
|
||||
let iconName = "AltIcon"
|
||||
let iconURL = appBundleURL.appendingPathComponent(iconName + "@\(iconScale)x.png")
|
||||
try iconData.write(to: iconURL, options: .atomic)
|
||||
|
||||
let iconDictionary = ["CFBundlePrimaryIcon": ["CFBundleIconFiles": [iconName]]]
|
||||
additionalValues["CFBundleIcons"] = iconDictionary
|
||||
}
|
||||
|
||||
// Prepare app
|
||||
try prepare(appBundle, additionalInfoDictionaryValues: additionalValues)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user