mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltStoreCore] Adds AppProtocol.storeApp
Simplifies retrieving the associated StoreApp for an app.
This commit is contained in:
@@ -1463,7 +1463,7 @@ private extension AppManager
|
||||
let patchAppURL = URL(string: patchAppLink)
|
||||
else { throw OperationError.invalidApp }
|
||||
|
||||
let patchApp = AnyApp(name: app.name, bundleIdentifier: app.bundleIdentifier, url: patchAppURL)
|
||||
let patchApp = AnyApp(name: app.name, bundleIdentifier: app.bundleIdentifier, url: patchAppURL, storeApp: nil)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
let storyboard = UIStoryboard(name: "PatchApp", bundle: nil)
|
||||
|
||||
@@ -109,7 +109,7 @@ final class PatchAppOperation: ResultOperation<Void>
|
||||
.flatMap { self.patch(resignedApp, withBinaryAt: $0) }
|
||||
.tryMap { try FileManager.default.zipAppBundle(at: $0) }
|
||||
.tryMap { (fileURL) in
|
||||
let app = AnyApp(name: resignedApp.name, bundleIdentifier: self.context.bundleIdentifier, url: resignedApp.fileURL)
|
||||
let app = AnyApp(name: resignedApp.name, bundleIdentifier: self.context.bundleIdentifier, url: resignedApp.fileURL, storeApp: nil)
|
||||
|
||||
let destinationURL = InstalledApp.refreshedIPAURL(for: app)
|
||||
try FileManager.default.copyItem(at: fileURL, to: destinationURL, shouldReplace: true)
|
||||
|
||||
@@ -43,7 +43,7 @@ final class SendAppOperation: ResultOperation<()>
|
||||
Logger.sideload.notice("Sending app \(self.context.bundleIdentifier, privacy: .public) to AltServer \(server.localizedName ?? "nil", privacy: .public)...")
|
||||
|
||||
// self.context.resignedApp.fileURL points to the app bundle, but we want the .ipa.
|
||||
let app = AnyApp(name: resignedApp.name, bundleIdentifier: self.context.bundleIdentifier, url: resignedApp.fileURL)
|
||||
let app = AnyApp(name: resignedApp.name, bundleIdentifier: self.context.bundleIdentifier, url: resignedApp.fileURL, storeApp: nil)
|
||||
let fileURL = InstalledApp.refreshedIPAURL(for: app)
|
||||
|
||||
print("AFC App `fileURL`: \(fileURL.absoluteString)")
|
||||
|
||||
@@ -104,7 +104,7 @@ public extension LoggedError
|
||||
{
|
||||
var app: AppProtocol {
|
||||
// `as AppProtocol` needed to fix "cannot convert AnyApp to StoreApp" compiler error with Xcode 14.
|
||||
let app = self.installedApp ?? self.storeApp ?? AnyApp(name: self.appName, bundleIdentifier: self.appBundleID, url: nil) as AppProtocol
|
||||
let app = self.installedApp ?? self.storeApp ?? AnyApp(name: self.appName, bundleIdentifier: self.appBundleID, url: nil, storeApp: nil) as AppProtocol
|
||||
return app
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ public protocol AppProtocol
|
||||
var name: String { get }
|
||||
var bundleIdentifier: String { get }
|
||||
var url: URL? { get }
|
||||
|
||||
var storeApp: StoreApp? { get }
|
||||
}
|
||||
|
||||
public struct AnyApp: AppProtocol
|
||||
@@ -21,12 +23,14 @@ public struct AnyApp: AppProtocol
|
||||
public var name: String
|
||||
public var bundleIdentifier: String
|
||||
public var url: URL?
|
||||
public var storeApp: StoreApp?
|
||||
|
||||
public init(name: String, bundleIdentifier: String, url: URL?)
|
||||
public init(name: String, bundleIdentifier: String, url: URL?, storeApp: StoreApp?)
|
||||
{
|
||||
self.name = name
|
||||
self.bundleIdentifier = bundleIdentifier
|
||||
self.url = url
|
||||
self.storeApp = storeApp
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +39,10 @@ extension ALTApplication: AppProtocol
|
||||
public var url: URL? {
|
||||
return self.fileURL
|
||||
}
|
||||
|
||||
public var storeApp: StoreApp? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreApp: AppProtocol
|
||||
@@ -42,6 +50,10 @@ extension StoreApp: AppProtocol
|
||||
public var url: URL? {
|
||||
return self.latestAvailableVersion?.downloadURL
|
||||
}
|
||||
|
||||
public var storeApp: StoreApp? {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
extension InstalledApp: AppProtocol
|
||||
@@ -63,4 +75,8 @@ extension AppVersion: AppProtocol {
|
||||
public var url: URL? {
|
||||
return self.downloadURL
|
||||
}
|
||||
|
||||
public var storeApp: StoreApp? {
|
||||
return self.app
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user