ref: make app plist required
This commit is contained in:
@@ -22,7 +22,10 @@ class ThumbnailProvider: QLThumbnailProvider {
|
||||
|
||||
override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) {
|
||||
let meta = MetaInfo(request.fileURL)
|
||||
let img = AppIcon(meta).extractImage(from: meta.readPlistApp()).withRoundCorners()
|
||||
guard let appPlist = meta.readPlistApp() else {
|
||||
return
|
||||
}
|
||||
let img = AppIcon(meta).extractImage(from: appPlist).withRoundCorners()
|
||||
|
||||
// First way: Draw the thumbnail into the current context, set up with UIKit's coordinate system.
|
||||
let reply = QLThumbnailReply(contextSize: request.maximumSize, currentContextDrawing: { () -> Bool in
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<style>__CSS__</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app __AppInfoHidden__">
|
||||
<div class="app">
|
||||
<h1>__AppInfoTitle__</h1>
|
||||
<div class="floatLeft icon"><img alt="App icon" src="data:image/png;base64,__AppIcon__"/></div>
|
||||
<div class="floatLeft info">
|
||||
@@ -25,14 +25,8 @@
|
||||
</div>
|
||||
|
||||
<div class="__ProvisionHidden__">
|
||||
<div class="__AppInfoHidden__">
|
||||
<h2>Provisioning</h2>
|
||||
Profile name: <strong>__ProvisionProfileName__</strong><br />
|
||||
</div>
|
||||
<div class="__ProvisionTitleHidden__">
|
||||
<h1><span class="__ProvisionExpireStatus__">__ProvisionProfileName__</span></h1>
|
||||
</div>
|
||||
|
||||
Profile UUID: __ProvisionProfileId__<br />
|
||||
Profile Type: __ProvisionProfilePlatform__ __ProvisionProfileType__<br />
|
||||
Team: __ProvisionTeamName__ (__ProvisionTeamIds__)<br />
|
||||
@@ -42,7 +36,7 @@
|
||||
|
||||
<div>
|
||||
<h2>Entitlements</h2>
|
||||
<div class="__EntitlementsWarningHidden__ warning">
|
||||
<div class="warning __EntitlementsWarningHidden__">
|
||||
<strong>Entitlements extraction failed.</strong>
|
||||
</div>
|
||||
__EntitlementsDict__
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ?? "",
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user