From a4d7d943016fff2472422ca63fa1601f690ec8ac Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Mon, 4 Oct 2021 15:36:16 -0700 Subject: [PATCH] [AltServer] Fixes not ignoring InstallationError.cancelled when installing app Allows InstallationError to be bridged back from NSError, which lets us match InstallationError against NSError's via pattern matching. --- .../Devices/ALTDeviceManager+Installation.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/AltServer/Devices/ALTDeviceManager+Installation.swift b/AltServer/Devices/ALTDeviceManager+Installation.swift index e2c931b2..6346db94 100644 --- a/AltServer/Devices/ALTDeviceManager+Installation.swift +++ b/AltServer/Devices/ALTDeviceManager+Installation.swift @@ -14,7 +14,7 @@ private let appGroupsLock = NSLock() private let developerDiskManager = DeveloperDiskManager() -enum InstallError: LocalizedError +enum InstallError: Int, LocalizedError, _ObjectiveCBridgeableError { case cancelled case noTeam @@ -30,6 +30,20 @@ enum InstallError: LocalizedError case .missingCertificate: return "The developer certificate could not be found." } } + + init?(_bridgedNSError error: NSError) + { + guard error.domain == InstallError.cancelled._domain else { return nil } + + if let installError = InstallError(rawValue: error.code) + { + self = installError + } + else + { + return nil + } + } } extension ALTDeviceManager