Throws error if marketplace app is missing buildVersion

This commit is contained in:
Riley Testut
2024-02-15 18:39:27 -06:00
committed by Magesh K
parent 07ed25ab54
commit d2ed5bff57
2 changed files with 28 additions and 1 deletions

View File

@@ -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

View File

@@ -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)