From 4667841c8dd12bb66c5405574f7030f7ba61adfd Mon Sep 17 00:00:00 2001 From: nythepegasus Date: Thu, 9 May 2024 00:20:30 -0400 Subject: [PATCH] Parses AppVersion.minOSVersion/maxOSVersion from source JSON --- AltStoreCore/Model/AppVersion.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AltStoreCore/Model/AppVersion.swift b/AltStoreCore/Model/AppVersion.swift index dc0ffe80..119d14bc 100644 --- a/AltStoreCore/Model/AppVersion.swift +++ b/AltStoreCore/Model/AppVersion.swift @@ -54,6 +54,8 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable case localizedDescription case downloadURL case size + case minOSVersion + case maxOSVersion } public required init(from decoder: Decoder) throws @@ -72,6 +74,9 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable self.downloadURL = try container.decode(URL.self, forKey: .downloadURL) self.size = try container.decode(Int64.self, forKey: .size) + + self._minOSVersion = try container.decodeIfPresent(String.self, forKey: .minOSVersion) + self._maxOSVersion = try container.decodeIfPresent(String.self, forKey: .maxOSVersion) } catch { @@ -115,6 +120,11 @@ public extension AppVersion } var isSupported: Bool { + if let minOSVersion = self.minOSVersion, !ProcessInfo.processInfo.isOperatingSystemAtLeast(minOSVersion) { + return false + } else if let maxOSVersion = self.maxOSVersion, ProcessInfo.processInfo.operatingSystemVersion > maxOSVersion { + return false + } return true } }