From 4fa020beb0985e7c0dd287f0a86d6e528063e9ed Mon Sep 17 00:00:00 2001 From: Stephen B <158498287+StephenDev0@users.noreply.github.com> Date: Sun, 26 Oct 2025 22:49:11 -0400 Subject: [PATCH] Added redownload ddi button --- StikJIT/StikJITApp.swift | 44 ++++++++++++++++++++++++++++++++ StikJIT/Views/SettingsView.swift | 15 +++++++++++ 2 files changed, 59 insertions(+) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index fc3be93..ad2ff01 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -1102,3 +1102,47 @@ func downloadFile(from urlString: String, to destinationURL: URL, completion: @e task.resume() completion("") } + +func redownloadDDI() { + let fileManager = FileManager.default + let ddiFiles = [ + "DDI/BuildManifest.plist", + "DDI/Image.dmg", + "DDI/Image.dmg.trustcache" + ] + + for file in ddiFiles { + let fileURL = URL.documentsDirectory.appendingPathComponent(file) + if fileManager.fileExists(atPath: fileURL.path) { + do { + try fileManager.removeItem(at: fileURL) + print("Deleted \(file)") + } catch { + print("Error deleting \(file): \(error)") + } + } + } + + let urls = [ + "https://github.com/doronz88/DeveloperDiskImage/raw/refs/heads/main/PersonalizedImages/Xcode_iOS_DDI_Personalized/BuildManifest.plist", + "https://github.com/doronz88/DeveloperDiskImage/raw/refs/heads/main/PersonalizedImages/Xcode_iOS_DDI_Personalized/Image.dmg", + "https://github.com/doronz88/DeveloperDiskImage/raw/refs/heads/main/PersonalizedImages/Xcode_iOS_DDI_Personalized/Image.dmg.trustcache" + ] + + let group = DispatchGroup() + + for (index, urlString) in urls.enumerated() { + let destinationURL = URL.documentsDirectory.appendingPathComponent(ddiFiles[index]) + group.enter() + downloadFile(from: urlString, to: destinationURL) { result in + if (result != "") { + showAlert(title: "An Error has Occurred", message: "[Download DDI Error]: " + result, showOk: true) + } + group.leave() + } + } + + group.notify(queue: .main) { + showAlert(title: "Success", message: "DDI files have been redownloaded.", showOk: true) + } +} diff --git a/StikJIT/Views/SettingsView.swift b/StikJIT/Views/SettingsView.swift index aae96d4..4e58f08 100644 --- a/StikJIT/Views/SettingsView.swift +++ b/StikJIT/Views/SettingsView.swift @@ -383,6 +383,17 @@ struct SettingsView: View { } .padding(.vertical, 8) } + Button(action: { redownloadDDIPressed() }) { + HStack { + Image(systemName: "arrow.down.circle") + .font(.system(size: 18)) + .foregroundColor(.primary.opacity(0.8)) + Text("Redownload DDI") + .foregroundColor(.primary.opacity(0.8)) + Spacer() + } + .padding(.vertical, 8) + } } } } @@ -515,6 +526,10 @@ struct SettingsView: View { } } } + + private func redownloadDDIPressed() { + redownloadDDI() + } } // MARK: - Helper Components