From 8534e2850b94a3715c2343f5230a0d9da2e94047 Mon Sep 17 00:00:00 2001 From: Matt Kiazyk Date: Fri, 8 Mar 2024 12:16:20 -0600 Subject: [PATCH] fix runtime not appearing when multiple runtimes exist for same build --- Xcodes/Backend/AppState+Runtimes.swift | 4 ++-- Xcodes/Frontend/InfoPane/InfoPane.swift | 4 ++-- Xcodes/Frontend/InfoPane/PlatformsView.swift | 2 +- .../Sources/XcodesKit/Models/Runtimes/Runtimes.swift | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Xcodes/Backend/AppState+Runtimes.swift b/Xcodes/Backend/AppState+Runtimes.swift index 81abc5b3..838f1856 100644 --- a/Xcodes/Backend/AppState+Runtimes.swift +++ b/Xcodes/Backend/AppState+Runtimes.swift @@ -15,10 +15,10 @@ extension AppState { var updatedRuntime = runtime // This loops through and matches up the simulatorVersion to the mappings - let simulatorBuildUpdate = downloadableRuntimes.sdkToSimulatorMappings.first { SDKToSimulatorMapping in + let simulatorBuildUpdate = downloadableRuntimes.sdkToSimulatorMappings.filter { SDKToSimulatorMapping in SDKToSimulatorMapping.simulatorBuildUpdate == runtime.simulatorVersion.buildUpdate } - updatedRuntime.sdkBuildUpdate = simulatorBuildUpdate?.sdkBuildUpdate + updatedRuntime.sdkBuildUpdate = simulatorBuildUpdate.map { $0.sdkBuildUpdate } return updatedRuntime } diff --git a/Xcodes/Frontend/InfoPane/InfoPane.swift b/Xcodes/Frontend/InfoPane/InfoPane.swift index 95826b73..0448f661 100644 --- a/Xcodes/Frontend/InfoPane/InfoPane.swift +++ b/Xcodes/Frontend/InfoPane/InfoPane.swift @@ -146,12 +146,12 @@ var xcodeDict: [XcodePreviewName: Xcode] = [ var downloadableRuntimes: [DownloadableRuntime] = { var runtimes = try! JSONDecoder().decode([DownloadableRuntime].self, from: Current.files.contents(atPath: Path.runtimeCacheFile.string)!) // set iOS to installed - let iOSIndex = runtimes.firstIndex { $0.sdkBuildUpdate == "19E239" }! + let iOSIndex = 0//runtimes.firstIndex { $0.sdkBuildUpdate.contains == "19E239" }! var iOSRuntime = runtimes[iOSIndex] iOSRuntime.installState = .installed runtimes[iOSIndex] = iOSRuntime - let watchOSIndex = runtimes.firstIndex { $0.sdkBuildUpdate == "20R362" }! + let watchOSIndex = 0//runtimes.firstIndex { $0.sdkBuildUpdate.first == "20R362" }! var runtime = runtimes[watchOSIndex] runtime.installState = .installing( RuntimeInstallationStep.downloading( diff --git a/Xcodes/Frontend/InfoPane/PlatformsView.swift b/Xcodes/Frontend/InfoPane/PlatformsView.swift index 93b2d3bb..1c946ee1 100644 --- a/Xcodes/Frontend/InfoPane/PlatformsView.swift +++ b/Xcodes/Frontend/InfoPane/PlatformsView.swift @@ -19,7 +19,7 @@ struct PlatformsView: View { let builds = xcode.sdks?.allBuilds() let runtimes = builds?.flatMap { sdkBuild in appState.downloadableRuntimes.filter { - $0.sdkBuildUpdate == sdkBuild + $0.sdkBuildUpdate?.contains(sdkBuild) ?? false } } diff --git a/Xcodes/XcodesKit/Sources/XcodesKit/Models/Runtimes/Runtimes.swift b/Xcodes/XcodesKit/Sources/XcodesKit/Models/Runtimes/Runtimes.swift index 26289ee8..23cfb332 100644 --- a/Xcodes/XcodesKit/Sources/XcodesKit/Models/Runtimes/Runtimes.swift +++ b/Xcodes/XcodesKit/Sources/XcodesKit/Models/Runtimes/Runtimes.swift @@ -30,7 +30,7 @@ public struct DownloadableRuntime: Codable, Identifiable, Hashable { // dynamically updated - not decoded public var installState: RuntimeInstallState = .notInstalled - public var sdkBuildUpdate: String? + public var sdkBuildUpdate: [String]? enum CodingKeys: CodingKey { case category