ref: make app plist required

This commit is contained in:
relikd
2025-11-04 19:45:29 +01:00
parent 6898eeb42c
commit 96001e4d40
6 changed files with 22 additions and 35 deletions

View File

@@ -15,7 +15,7 @@ struct AppIcon {
/// 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.
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
if meta.type == .IPA {
if let data = meta.zipFile!.unzipFile("iTunesArtwork") {
@@ -68,8 +68,7 @@ extension AppIcon {
/// Parse app plist to find the bundle icon filename.
/// @param appPlist If `nil`, will load plist on the fly (used for thumbnail)
/// @return Filenames which do not necessarily exist on filesystem. This may include `@2x` and/or no file extension.
private func iconNamesFromPlist(_ appPlist: PlistDict?) -> [String] {
let appPlist = appPlist == nil ? meta.readPlistApp()! : appPlist!
private func iconNamesFromPlist(_ appPlist: PlistDict) -> [String] {
// Check for CFBundleIcons (since 5.0)
if let icons = unpackNameListFromPlistDict(appPlist["CFBundleIcons"]), !icons.isEmpty {
return icons

View File

@@ -57,15 +57,7 @@ extension PreviewGenerator {
}
/// Process info stored in `Info.plist`
mutating func procAppInfo(_ appPlist: PlistDict?) {
guard let appPlist else {
self.apply([
"AppInfoHidden": CLASS_HIDDEN,
"ProvisionTitleHidden": "",
])
return
}
mutating func procAppInfo(_ appPlist: PlistDict) {
var platforms = (appPlist["UIDeviceFamily"] as? [Int])?.compactMap({
switch $0 {
case 1: return "iPhone"
@@ -83,9 +75,6 @@ extension PreviewGenerator {
let extensionType = (appPlist["NSExtension"] as? PlistDict)?["NSExtensionPointIdentifier"] as? String
self.apply([
"AppInfoHidden": "",
"ProvisionTitleHidden": CLASS_HIDDEN,
"AppName": appPlist["CFBundleDisplayName"] as? String ?? appPlist["CFBundleName"] as? String ?? "",
"AppVersion": appPlist["CFBundleShortVersionString"] as? String ?? "",
"AppBuildVer": appPlist["CFBundleVersion"] as? String ?? "",

View File

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

View File

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