diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index 66dd9121..8f27ae7c 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -1246,7 +1246,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) diff --git a/AltStore/Operations/Patch App/PatchAppOperation.swift b/AltStore/Operations/Patch App/PatchAppOperation.swift index 951f5924..42dc76ff 100644 --- a/AltStore/Operations/Patch App/PatchAppOperation.swift +++ b/AltStore/Operations/Patch App/PatchAppOperation.swift @@ -110,7 +110,7 @@ class PatchAppOperation: ResultOperation .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) diff --git a/AltStore/Operations/SendAppOperation.swift b/AltStore/Operations/SendAppOperation.swift index 2fd61569..191b340b 100644 --- a/AltStore/Operations/SendAppOperation.swift +++ b/AltStore/Operations/SendAppOperation.swift @@ -44,7 +44,7 @@ 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) // Connect to server. diff --git a/AltStoreCore/Model/LoggedError.swift b/AltStoreCore/Model/LoggedError.swift index 6aba7127..0a22dd45 100644 --- a/AltStoreCore/Model/LoggedError.swift +++ b/AltStoreCore/Model/LoggedError.swift @@ -107,7 +107,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 } diff --git a/AltStoreCore/Protocols/AppProtocol.swift b/AltStoreCore/Protocols/AppProtocol.swift index 2f4c1af0..98cda889 100644 --- a/AltStoreCore/Protocols/AppProtocol.swift +++ b/AltStoreCore/Protocols/AppProtocol.swift @@ -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 @@ -64,4 +76,8 @@ extension AppVersion: AppProtocol public var url: URL? { return self.downloadURL } + + public var storeApp: StoreApp? { + return self.app + } }