feat: make appPlist optional (again)

This commit is contained in:
relikd
2025-11-05 18:36:45 +01:00
parent af9c398571
commit f38c1f802f
4 changed files with 10 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ struct AppIcon {
/// Try multiple methods to extract image. /// Try multiple methods to extract image.
/// This method will always return an image even if none is found, in which case it returns the default image. /// This method will always return an image even if none is found, in which case it returns the default image.
func extractImage(from appPlist: PlistDict) -> NSImage { func extractImage(from appPlist: PlistDict?) -> NSImage {
// no need to unwrap the plist, and most .ipa should include the Artwork anyway // no need to unwrap the plist, and most .ipa should include the Artwork anyway
if meta.type == .IPA { if meta.type == .IPA {
if let data = meta.zipFile!.unzipFile("iTunesArtwork") { if let data = meta.zipFile!.unzipFile("iTunesArtwork") {
@@ -25,12 +25,13 @@ struct AppIcon {
} }
// Extract image name from app plist // Extract image name from app plist
var plistImgNames = iconNamesFromPlist(appPlist) var plistImgNames = (appPlist == nil) ? [] : iconNamesFromPlist(appPlist!)
os_log(.debug, log: log, "[icon] icon names in plist: %{public}@", plistImgNames) os_log(.debug, log: log, "[icon] icon names in plist: %{public}@", plistImgNames)
// If no previous filename works (or empty), try default icon names // If no previous filename works (or empty), try default icon names
plistImgNames.append("Icon") plistImgNames.append("Icon")
plistImgNames.append("icon") plistImgNames.append("icon")
plistImgNames.append("AppIcon")
// First, try if an image file with that name exists. // First, try if an image file with that name exists.
if let actualName = expandImageName(plistImgNames) { if let actualName = expandImageName(plistImgNames) {

View File

@@ -78,7 +78,10 @@ extension PreviewGenerator {
} }
/// Process info stored in `Info.plist` /// Process info stored in `Info.plist`
mutating func procAppInfo(_ appPlist: PlistDict, isOSX: Bool) { mutating func procAppInfo(_ appPlist: PlistDict?, isOSX: Bool) {
guard let appPlist else {
return
}
let minVersion = appPlist[isOSX ? "LSMinimumSystemVersion" : "MinimumOSVersion"] as? String ?? "" let minVersion = appPlist[isOSX ? "LSMinimumSystemVersion" : "MinimumOSVersion"] as? String ?? ""
let extensionType = (appPlist["NSExtension"] as? PlistDict)?["NSExtensionPointIdentifier"] as? String let extensionType = (appPlist["NSExtension"] as? PlistDict)?["NSExtensionPointIdentifier"] as? String

View File

@@ -22,8 +22,8 @@ extension PreviewGenerator {
} }
/// Process compiled binary and provision plist to extract `Entitlements` /// Process compiled binary and provision plist to extract `Entitlements`
mutating func procEntitlements(_ meta: MetaInfo, _ appPlist: PlistDict, _ provisionPlist: PlistDict?) { mutating func procEntitlements(_ meta: MetaInfo, _ appPlist: PlistDict?, _ provisionPlist: PlistDict?) {
var entitlements = readEntitlements(meta, appPlist["CFBundleExecutable"] as? String) var entitlements = readEntitlements(meta, appPlist?["CFBundleExecutable"] as? String)
entitlements.applyFallbackIfNeeded(provisionPlist?["Entitlements"] as? PlistDict) entitlements.applyFallbackIfNeeded(provisionPlist?["Entitlements"] as? PlistDict)
self.apply([ self.apply([

View File

@@ -8,9 +8,7 @@ struct PreviewGenerator {
init(_ meta: MetaInfo) { init(_ meta: MetaInfo) {
self.meta = meta self.meta = meta
guard let plistApp = meta.readPlistApp() else { let plistApp = meta.readPlistApp()
return
}
let plistItunes = meta.readPlistItunes() let plistItunes = meta.readPlistItunes()
let plistProvision = meta.readPlistProvision() let plistProvision = meta.readPlistProvision()