diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index 0380bb98..4e8ea028 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -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) diff --git a/AltStore/Operations/Patch App/PatchAppOperation.swift b/AltStore/Operations/Patch App/PatchAppOperation.swift index fd93134b..47f835dd 100644 --- a/AltStore/Operations/Patch App/PatchAppOperation.swift +++ b/AltStore/Operations/Patch App/PatchAppOperation.swift @@ -109,7 +109,7 @@ final 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 bf5ba7e8..cc8d40eb 100644 --- a/AltStore/Operations/SendAppOperation.swift +++ b/AltStore/Operations/SendAppOperation.swift @@ -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)") diff --git a/AltStoreCore/Model/LoggedError.swift b/AltStoreCore/Model/LoggedError.swift index 61a8234a..50c92bd3 100644 --- a/AltStoreCore/Model/LoggedError.swift +++ b/AltStoreCore/Model/LoggedError.swift @@ -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 } diff --git a/AltStoreCore/Protocols/AppProtocol.swift b/AltStoreCore/Protocols/AppProtocol.swift index 8b622933..22467274 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 @@ -63,4 +75,8 @@ extension AppVersion: AppProtocol { public var url: URL? { return self.downloadURL } + + public var storeApp: StoreApp? { + return self.app + } }