Run a virtual iPhone on an Apple Silicon Mac.
Swift
catalog: Add the recommended cloudOS for a resolved release
zqxwce10089f96b454
diff --git a/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift b/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swiftindex 911e5ebc..ede13d22 100644--- a/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift+++ b/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift@@ -666,11 +666,7 @@ public enum VPhoneFirmwareCatalog {}}return releases.map { release in- let cloudOS = switch guest.family {- case .appleTV, .homePod: VPhoneCloudOSOption(name: "cloudOS 26.4", url: cloud264)- case .watch: researchBoardCloudOS(forVersion: release.version) ?? recommendedCloudOS(forVersion: release.version)- case .iPhone, .iPad: recommendedCloudOS(forVersion: release.version)- }+ let cloudOS = recommendedCloudOS(for: guest.family, version: release.version)return VPhoneFirmwarePairing(device: guest.productType,iosName: "\(guest.family.osName) \(release.version)",@@ -681,6 +677,26 @@ public enum VPhoneFirmwareCatalog {}}+ /// The cloudOS for `device`'s release at `url`, of `version`: its pairing's,+ /// else the one the pairings give that version on its family.+ public static func recommendedCloudOS(forDevice device: String, version: String, url: String) -> VPhoneCloudOSOption {+ let guest = VPhoneGuestDevice.named(device)+ let pairings = pairings(for: device)+ let name = "\((guest?.family ?? .iPhone).osName) \(version)"+ if let pairing = pairings.first(where: { $0.iosURL == url }) ?? pairings.first(where: { $0.iosName == name }) {+ return VPhoneCloudOSOption(name: pairing.cloudosName, url: pairing.cloudosURL)+ }+ return recommendedCloudOS(for: guest?.family ?? .iPhone, version: version)+ }++ static func recommendedCloudOS(for family: VPhoneGuestDevice.Family, version: String) -> VPhoneCloudOSOption {+ switch family {+ case .appleTV, .homePod: VPhoneCloudOSOption(name: "cloudOS 26.4", url: cloud264)+ case .watch: researchBoardCloudOS(forVersion: version) ?? recommendedCloudOS(forVersion: version)+ case .iPhone, .iPad: recommendedCloudOS(forVersion: version)+ }+ }+/// The cloudOS the iPhone pairings give a release of this version.static func recommendedCloudOS(forVersion version: String) -> VPhoneCloudOSOption {switch version.split(separator: ".").prefix(2).joined(separator: ".") {diff --git a/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift b/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swiftindex b7bf324a..c1722402 100644--- a/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift@@ -265,6 +265,17 @@ struct FirmwareCatalogReportTests {}}+ @Test func `a resolved release gets its pairing's cloud OS, else its version's`() {+ for p in VPhoneFirmwareCatalog.pairings {+ let version = String(p.iosName.dropFirst("iOS ".count))+ #expect(VPhoneFirmwareCatalog.recommendedCloudOS(forDevice: "iPhone17,3", version: version, url: p.iosURL).url == p.cloudosURL)+ }+ // A curated pairing wins over the version rule, by URL or by name.+ #expect(VPhoneFirmwareCatalog.recommendedCloudOS(forDevice: "iPhone17,3", version: "18.6.2", url: "").url == VPhoneFirmwareCatalog.cloud261)+ #expect(VPhoneFirmwareCatalog.recommendedCloudOS(forDevice: "iPhone17,3", version: "26.2.9", url: "").url == VPhoneFirmwareCatalog.cloud262)+ #expect(VPhoneFirmwareCatalog.recommendedCloudOS(forDevice: "AppleTV5,3", version: "26.1", url: "").url == VPhoneFirmwareCatalog.cloud264)+ }+@Test func `round trips JSON`() throws {let report = VPhoneFirmwareCatalog.reportlet back = try JSONDecoder().decode(VPhoneFirmwareCatalogReport.self, from: JSONEncoder().encode(report))