diff --git a/AltStoreCore/Model/AppVersion.swift b/AltStoreCore/Model/AppVersion.swift index ddd4eece..36c6c850 100644 --- a/AltStoreCore/Model/AppVersion.swift +++ b/AltStoreCore/Model/AppVersion.swift @@ -56,7 +56,7 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable super.init(entity: entity, insertInto: context) } - private enum CodingKeys: String, CodingKey + internal enum CodingKeys: String, CodingKey { case version case buildVersion diff --git a/AltStoreCore/Model/StoreApp.swift b/AltStoreCore/Model/StoreApp.swift index 005b271b..9f9cbdd2 100644 --- a/AltStoreCore/Model/StoreApp.swift +++ b/AltStoreCore/Model/StoreApp.swift @@ -424,6 +424,33 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable for version in versions { version.appBundleID = self.bundleIdentifier + + if self.marketplaceID != nil + { + struct IndexCodingKey: CodingKey + { + var stringValue: String { self.intValue?.description ?? "" } + var intValue: Int? + + init?(stringValue: String) + { + fatalError() + } + + init(intValue: Int) + { + self.intValue = intValue + } + } + + // Marketplace apps must provide build version. + guard version.buildVersion != nil else { + let codingPath = container.codingPath + [CodingKeys.versions as CodingKey] + [IndexCodingKey(intValue: index) as CodingKey] + let context = DecodingError.Context(codingPath: codingPath, debugDescription: "Notarized apps must provide a build version.") + throw DecodingError.keyNotFound(AppVersion.CodingKeys.buildVersion, context) + } + } + } try self.setVersions(versions)