Skip to content

Commit c153a93

Browse files
committed
adjustments to update runtimes
1 parent f470986 commit c153a93

5 files changed

Lines changed: 83 additions & 5 deletions

File tree

Xcodes.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
36741BFD291E4FDB00A85AAE /* DownloadPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36741BFC291E4FDB00A85AAE /* DownloadPreferencePane.swift */; };
1111
36741BFF291E50F500A85AAE /* FileError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36741BFE291E50F500A85AAE /* FileError.swift */; };
12-
536CFDD2263C94DE00026CE0 /* SignedInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536CFDD1263C94DE00026CE0 /* SignedInView.swift */; };
12+
536CFDD2263C94DE00026CE0 /* SignedInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536CFDD1263C94DE00026CE0 /* SignedInView.swift */; };
1313
536CFDD4263C9A8000026CE0 /* XcodesSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536CFDD3263C9A8000026CE0 /* XcodesSheet.swift */; };
1414
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CBAB2B263DCC9100410495 /* XcodesAlert.swift */; };
1515
63EAA4EB259944450046AB8F /* ProgressButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EAA4EA259944450046AB8F /* ProgressButton.swift */; };
@@ -113,6 +113,7 @@
113113
E689540325BE8C64000EBCEA /* DockProgress in Frameworks */ = {isa = PBXBuildFile; productRef = E689540225BE8C64000EBCEA /* DockProgress */; };
114114
E81D7EA02805250100A205FC /* Collection+.swift in Sources */ = {isa = PBXBuildFile; fileRef = E81D7E9F2805250100A205FC /* Collection+.swift */; };
115115
E832EAF82B0FBCF4001B570D /* RuntimeInstallationStepDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E832EAF72B0FBCF4001B570D /* RuntimeInstallationStepDetailView.swift */; };
116+
E84CF8C12B0FEB8300ECA259 /* RuntimesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E84CF8C02B0FEB8300ECA259 /* RuntimesView.swift */; };
116117
E872EE4E2808D4F100D3DD8B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = E872EE502808D4F100D3DD8B /* Localizable.strings */; };
117118
E87AB3C52939B65E00D72F43 /* Hardware.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87AB3C42939B65E00D72F43 /* Hardware.swift */; };
118119
E87DD6EB25D053FA00D86808 /* Progress+.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87DD6EA25D053FA00D86808 /* Progress+.swift */; };
@@ -324,6 +325,7 @@
324325
E2AFDCCA28F024D000864ADD /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
325326
E81D7E9F2805250100A205FC /* Collection+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+.swift"; sourceTree = "<group>"; };
326327
E832EAF72B0FBCF4001B570D /* RuntimeInstallationStepDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuntimeInstallationStepDetailView.swift; sourceTree = "<group>"; };
328+
E84CF8C02B0FEB8300ECA259 /* RuntimesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuntimesView.swift; sourceTree = "<group>"; };
327329
E856BB73291EDD3D00DC438B /* XcodesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = XcodesKit; path = Xcodes/XcodesKit; sourceTree = "<group>"; };
328330
E872EE4F2808D4F100D3DD8B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
329331
E87AB3C42939B65E00D72F43 /* Hardware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hardware.swift; sourceTree = "<group>"; };
@@ -659,6 +661,7 @@
659661
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */,
660662
B0C6AD0C2AD91D7900E64698 /* IconView.swift */,
661663
E832EAF72B0FBCF4001B570D /* RuntimeInstallationStepDetailView.swift */,
664+
E84CF8C02B0FEB8300ECA259 /* RuntimesView.swift */,
662665
);
663666
path = InfoPane;
664667
sourceTree = "<group>";
@@ -880,6 +883,7 @@
880883
CA9FF8CF25959A9700E47BAF /* HelperXPCShared.swift in Sources */,
881884
CA735109257BF96D00EA9CF8 /* AttributedText.swift in Sources */,
882885
CAFBDC4E2599B33D003DCC5A /* MainToolbar.swift in Sources */,
886+
E84CF8C12B0FEB8300ECA259 /* RuntimesView.swift in Sources */,
883887
CA11E7BA2598476C00D2EE1C /* XcodeCommands.swift in Sources */,
884888
CAA8589B25A2B83000ACF8C0 /* Aria2CError.swift in Sources */,
885889
536CFDD2263C94DE00026CE0 /* SignedInView.swift in Sources */,

Xcodes/Backend/AppState+Runtimes.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ extension AppState {
5454
guard let index = self.downloadableRuntimes.firstIndex(where: { $0.identifier == runtime.identifier }) else { return }
5555
self.downloadableRuntimes[index].installState = .installed
5656
}
57+
58+
updateInstalledRuntimes()
5759
}
5860
catch {
5961
Logger.appState.error("Error downloading runtime: \(error.localizedDescription)")

Xcodes/Backend/AppState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ class AppState: ObservableObject {
824824

825825
// MARK: Runtimes
826826
func runtimeInstallPath(xcode: Xcode, runtime: DownloadableRuntime) -> Path? {
827-
if let coreSimulatorInfo = installedRuntimes.filter({ $0.runtimeInfo.build == runtime.sdkBuildUpdate }).first {
827+
if let coreSimulatorInfo = installedRuntimes.filter({ $0.runtimeInfo.build == runtime.simulatorVersion.buildUpdate }).first {
828828
let urlString = coreSimulatorInfo.path["relative"]!
829829
// app was not allowed to open up file:// url's so remove
830830
let fileRemovedString = urlString.replacingOccurrences(of: "file://", with: "")

Xcodes/Frontend/InfoPane/InfoPane.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ struct InfoPane: View {
2222
Divider()
2323

2424
Group {
25-
ReleaseNotesView(url: xcode.releaseNotesURL)
25+
RuntimesView(xcode: xcode)
2626
ReleaseDateView(date: xcode.releaseDate)
27+
ReleaseNotesView(url: xcode.releaseNotesURL)
2728
IdenticalBuildsView(builds: xcode.identicalBuilds)
2829
CompatibilityView(requiredMacOSVersion: xcode.requiredMacOSVersion)
2930
SDKsView(sdks: xcode.sdks)
@@ -44,8 +45,13 @@ struct InfoPane: View {
4445

4546
private func makePreviewContent(for index: Int) -> some View {
4647
let name = PreviewName.allCases[index]
47-
48-
})
48+
return InfoPane(xcode: xcodeDict[name]!)
49+
.environmentObject(configure(AppState()) {
50+
$0.allXcodes = [xcodeDict[name]!]
51+
})
52+
.frame(width: 300, height: 400)
53+
.padding()
54+
}
4955

5056
enum PreviewName: String, CaseIterable, Identifiable {
5157
case Populated_Installed_Selected
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//
2+
// RuntimesView.swift
3+
// Xcodes
4+
//
5+
// Created by Matt Kiazyk on 2023-11-23.
6+
// Copyright © 2023 Robots and Pencils. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
struct RuntimesView: View {
12+
@EnvironmentObject var appState: AppState
13+
let xcode: Xcode
14+
15+
var body: some View {
16+
VStack(alignment: .leading) {
17+
Text("Platforms")
18+
.font(.headline)
19+
.frame(maxWidth: .infinity, alignment: .leading)
20+
21+
let builds = xcode.sdks?.allBuilds()
22+
let runtimes = builds?.flatMap { sdkBuild in
23+
appState.downloadableRuntimes.filter {
24+
$0.sdkBuildUpdate == sdkBuild
25+
}
26+
}
27+
// let runtimes = appState.getRunTimes(xcode: xcode)
28+
29+
ForEach(runtimes ?? [], id: \.simulatorVersion.buildUpdate) { runtime in
30+
VStack {
31+
HStack {
32+
Text("\(runtime.visibleIdentifier)")
33+
.font(.subheadline)
34+
Spacer()
35+
Text(runtime.downloadFileSizeString)
36+
.font(.subheadline)
37+
38+
// it's installed if we have a path
39+
if let path = appState.runtimeInstallPath(xcode: xcode, runtime: runtime) {
40+
Button(action: { appState.reveal(path: path.string) }) {
41+
Image(systemName: "arrow.right.circle.fill")
42+
}
43+
.buttonStyle(PlainButtonStyle())
44+
.help("RevealInFinder")
45+
} else {
46+
DownloadRuntimeButton(runtime: runtime)
47+
}
48+
}
49+
switch runtime.installState {
50+
51+
case .installing(let installationStep):
52+
RuntimeInstallationStepDetailView(installationStep: installationStep)
53+
.fixedSize(horizontal: false, vertical: true)
54+
default:
55+
EmptyView()
56+
}
57+
}
58+
59+
}
60+
}
61+
}
62+
}
63+
64+
//#Preview {
65+
// RuntimesView()
66+
//}

0 commit comments

Comments
 (0)