From 6050c78613c48e69a8d8d8956763a6996898ddb3 Mon Sep 17 00:00:00 2001 From: Matt Kiazyk Date: Tue, 15 Oct 2024 22:07:53 -0500 Subject: [PATCH] allow cancelling of runtime downloads, cleanup --- Xcodes/Backend/AppState+Runtimes.swift | 10 +- Xcodes/Resources/Localizable.xcstrings | 125 +++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 3 deletions(-) diff --git a/Xcodes/Backend/AppState+Runtimes.swift b/Xcodes/Backend/AppState+Runtimes.swift index 33953ae8..e2b1149c 100644 --- a/Xcodes/Backend/AppState+Runtimes.swift +++ b/Xcodes/Backend/AppState+Runtimes.swift @@ -66,7 +66,7 @@ extension AppState { // not supported Logger.appState.error("Trying to download a runtime we can't download") DispatchQueue.main.async { - self.presentedAlert = .generic(title: localizeString("Alert.Install.Error.Title"), message: "Sorry. Apple only supports downloading runtimes iOS 18+, tvOS 18+, watchOS 11+, visionOS 2+ with Xcode 16.1+. Please download and make active.") + self.presentedAlert = .generic(title: localizeString("Alert.Install.Error.Title"), message: localizeString("Alert.Install.Error.Need.Xcode16.1")) } return } @@ -76,9 +76,12 @@ extension AppState { } func downloadRuntimeViaXcodeBuild(runtime: DownloadableRuntime) { - runtimePublishers[runtime.identifier] = Task { + + let downloadRuntimeTask = Current.shell.downloadRuntime(runtime.platform.shortName, runtime.simulatorVersion.buildUpdate) + runtimePublishers[runtime.identifier] = Task { [weak self] in + guard let self = self else { return } do { - for try await progress in Current.shell.downloadRuntime(runtime.platform.shortName, runtime.simulatorVersion.buildUpdate) { + for try await progress in downloadRuntimeTask { if progress.isIndeterminate { DispatchQueue.main.async { self.setInstallationStep(of: runtime, to: .installing, postNotification: false) @@ -91,6 +94,7 @@ extension AppState { } Logger.appState.debug("Done downloading runtime - \(runtime.name)") + DispatchQueue.main.async { guard let index = self.downloadableRuntimes.firstIndex(where: { $0.identifier == runtime.identifier }) else { return } self.downloadableRuntimes[index].installState = .installed diff --git a/Xcodes/Resources/Localizable.xcstrings b/Xcodes/Resources/Localizable.xcstrings index 112be7d4..d838911a 100644 --- a/Xcodes/Resources/Localizable.xcstrings +++ b/Xcodes/Resources/Localizable.xcstrings @@ -1958,6 +1958,131 @@ } } }, + "Alert.Install.Error.Need.Xcode16.1" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "ca" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "el" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "fi" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "hi" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "pt-BR" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "ru" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "uk" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "Apple only supports downloading runtimes iOS 16.0+, watchOS 9.0+, tvOS 16+, visionOS 1.0+ with Xcode 16.1+. Please download, make active and try again." + } + } + } + }, "Alert.Install.Error.Title" : { "comment" : "Install", "extractionState" : "manual",