ref: data structures for plist files

This commit is contained in:
relikd
2025-11-30 15:36:34 +01:00
parent be65aaa19a
commit 72e395c5da
16 changed files with 430 additions and 292 deletions

View File

@@ -1,45 +1,21 @@
import Foundation
extension PreviewGenerator {
private func deviceFamilyList(_ appPlist: PlistDict, isOSX: Bool) -> String {
if isOSX {
return (appPlist["CFBundleSupportedPlatforms"] as? [String])?.joined(separator: ", ") ?? "macOS"
}
let platforms = (appPlist["UIDeviceFamily"] as? [Int])?.compactMap({
switch $0 {
case 1: return "iPhone"
case 2: return "iPad"
case 3: return "TV"
case 4: return "Watch"
default: return nil
}
}).joined(separator: ", ")
let minVersion = appPlist["MinimumOSVersion"] as? String ?? ""
if platforms?.isEmpty ?? true, minVersion.hasPrefix("1.") || minVersion.hasPrefix("2.") || minVersion.hasPrefix("3.") {
return "iPhone"
}
return platforms ?? ""
}
/// Process info stored in `Info.plist`
mutating func procAppInfoApple(_ appPlist: PlistDict, isOSX: Bool) {
let minVersion = appPlist[isOSX ? "LSMinimumSystemVersion" : "MinimumOSVersion"] as? String ?? ""
let extensionType = (appPlist["NSExtension"] as? PlistDict)?["NSExtensionPointIdentifier"] as? String
mutating func procAppInfoApple(_ appPlist: Plist_Info) {
self.apply([
"AppInfoHidden": CLASS_VISIBLE,
"AppName": appPlist["CFBundleDisplayName"] as? String ?? appPlist["CFBundleName"] as? String ?? "",
"AppVersion": appPlist["CFBundleShortVersionString"] as? String ?? "",
"AppBuildVer": appPlist["CFBundleVersion"] as? String ?? "",
"AppId": appPlist["CFBundleIdentifier"] as? String ?? "",
"AppName": appPlist.name ?? "",
"AppVersion": appPlist.version ?? "",
"AppBuildVer": appPlist.buildVersion ?? "",
"AppId": appPlist.bundleId ?? "",
"AppExtensionTypeHidden": extensionType != nil ? CLASS_VISIBLE : CLASS_HIDDEN,
"AppExtensionType": extensionType ?? "",
"AppExtensionTypeHidden": appPlist.extensionType != nil ? CLASS_VISIBLE : CLASS_HIDDEN,
"AppExtensionType": appPlist.extensionType ?? "",
"AppDeviceFamily": deviceFamilyList(appPlist, isOSX: isOSX),
"AppSDK": appPlist["DTSDKName"] as? String ?? "",
"AppMinOS": minVersion,
"AppDeviceFamily": appPlist.deviceFamily.joined(separator: ", "),
"AppSDK": appPlist.sdkVersion ?? "",
"AppMinOS": appPlist.minOS ?? "",
])
}