Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Regroup machine actions, widen log sheets, simplify Templates

Lakr83b791d8ea6a
diff --git a/VPhoneLaunchpad/Tests/IPSWCacheTests.swift b/VPhoneLaunchpad/Tests/IPSWCacheTests.swift
index 7bbddf5a..a60f10e2 100644
--- a/VPhoneLaunchpad/Tests/IPSWCacheTests.swift
+++ b/VPhoneLaunchpad/Tests/IPSWCacheTests.swift
@@ -301,8 +301,9 @@ struct IPSWCacheTests {
// MARK: - Deletion rules
- /// A restored machine does not hold its IPSW; a creation that has not
- /// finished does, and a partial file waits while any creation runs.
+ /// A restored machine does not need its IPSW; a creation that has not
+ /// finished does, and a partial file is in use while any creation runs.
+ /// Neither refuses the deletion: the confirmation says what it breaks.
static func deletion() {
let url = "https://updates.cdn-apple.com/x/iPhone17,3_27.0_24A435_Restore.ipsw"
let cached = VPhoneLaunchpadIPSW.cacheName(for: URL(string: url)!)
@@ -314,16 +315,16 @@ struct IPSWCacheTests {
let finished = VPhoneLaunchpadIPSWUse(machine: "made", sources: [url])
let otherSource = VPhoneLaunchpadIPSWUse(machine: "other", sources: [rcSource], isCreating: true, needsSources: true)
typealias Rows = VPhoneLaunchpadIPSWRows
- expect(restored.uses(phone) && Rows.deletionBlock(phone, uses: [restored, finished], isCreating: false) == nil, "restored and finished do not hold it")
- expect(Rows.deletionBlock(phone, uses: [otherSource], isCreating: true) == nil, "a creation from another IPSW does not hold it")
- let held = Rows.deletionBlock(phone, uses: [running], isCreating: true)
+ expect(restored.uses(phone) && Rows.deletionWarning(phone, uses: [restored, finished], isCreating: false) == nil, "restored and finished need nothing")
+ expect(Rows.deletionWarning(phone, uses: [otherSource], isCreating: true) == nil, "a creation from another IPSW needs nothing")
+ let held = Rows.deletionWarning(phone, uses: [running], isCreating: true)
expect(held == "Creating new reads this IPSW until the creation finishes.", String(describing: held))
- expect(Rows.deletionBlock(phone, uses: [failed], isCreating: false)?.contains("retry") == true, "an unfinished creation holds it")
- expect(Rows.deletionBlock(phone, uses: [running, failed], isCreating: true)?.contains("new, retry") == true, "both creations named")
- expect(Rows.deletionBlock(partial, uses: [], isCreating: true) == "This IPSW is still downloading.", "a partial file waits while a creation runs")
- expect(Rows.deletionBlock(partial, uses: [], isCreating: false) == nil, "a stale partial file can go")
+ expect(Rows.deletionWarning(phone, uses: [failed], isCreating: false)?.contains("retry") == true, "an unfinished creation is warned about")
+ expect(Rows.deletionWarning(phone, uses: [running, failed], isCreating: true)?.contains("new, retry") == true, "both creations named")
+ expect(Rows.deletionWarning(partial, uses: [], isCreating: true) == "This IPSW is still downloading.", "a partial file warns while a creation runs")
+ expect(Rows.deletionWarning(partial, uses: [], isCreating: false) == nil, "a stale partial file can go")
let rows = Rows.rows([phone], catalog: nil, uses: [restored, failed])
- expect(rows[0].blockedReason != nil && rows[0].usedBy == ["done", "retry"], "\(rows[0])")
+ expect(rows[0].deletionWarning != nil && rows[0].usedBy == ["done", "retry"], "\(rows[0])")
// The confirmation names the file, the machines that keep working and
// what brings it back.
@@ -333,6 +334,8 @@ struct IPSWCacheTests {
expect(Rows.deletionMessage(row) == "\(cached) is deleted from the IPSW cache. Creating a machine from this release downloads it again.", Rows.deletionMessage(row))
let partialRow = Rows.rows([partial], catalog: nil, uses: [])[0]
expect(Rows.deletionMessage(partialRow) == "The partial download of \(cached) is deleted.", Rows.deletionMessage(partialRow))
+ let heldRow = Rows.rows([phone], catalog: nil, uses: [running], isCreating: true)[0]
+ expect(Rows.deletionMessage(heldRow).hasSuffix(" Creating new reads this IPSW until the creation finishes."), Rows.deletionMessage(heldRow))
}
// MARK: - Rows
@@ -352,8 +355,9 @@ struct IPSWCacheTests {
let rows = VPhoneLaunchpadIPSWRows.rows([unknownFile, cloudFile, padFile, phoneFile], catalog: catalog, uses: [pad, otherPad, creating])
expect(rows.map(\.kind) == [.iPhone, .iPad, .cloudOS, .unknown], "\(rows.map(\.kind))")
expect(rows[0].title == "iOS 27.0 RC (24A435)" && rows[0].usedBy == ["phone (creating)"], "\(rows[0])")
- expect(rows[0].kindLabel == "iPhone" && rows[0].blockedReason != nil, "\(rows[0])")
- expect(rows[1].title == "iPadOS 26.6.2 (23G90)" && rows[1].usedBy == ["ipad-mini-01"] && rows[1].blockedReason == nil, "\(rows[1])")
+ expect(rows[0].kindLabel == "iPhone" && rows[0].deletionWarning != nil, "\(rows[0])")
+ expect(rows[1].title == "iPadOS 26.6.2 (23G90)" && rows[1].usedBy == ["ipad-mini-01"] && rows[1].deletionWarning == nil, "\(rows[1])")
+ expect(rows[0].devices == "iPhone17,3" && rows[1].devices == "iPad16,1, iPad16,2" && rows[2].devices.isEmpty, "\(rows.map(\.devices))")
expect(rows[2].kindLabel == "cloudOS" && rows[2].title == "cloudOS 26.4 (23E5207q)", "\(rows[2])")
expect(rows[2].usedBy == ["ipad-mini-01", "ipad-pro-13"], "\(rows[2].usedBy)")
expect(rows[3].title == "mystery.ipsw" && rows[3].kindLabel == "Unknown", "\(rows[3])")
diff --git a/VPhoneLaunchpad/Tests/TemplatesTests.swift b/VPhoneLaunchpad/Tests/TemplatesTests.swift
index d847861c..099d72c2 100644
--- a/VPhoneLaunchpad/Tests/TemplatesTests.swift
+++ b/VPhoneLaunchpad/Tests/TemplatesTests.swift
@@ -21,12 +21,16 @@ struct TemplatesTests {
static func slimmingArguments() {
let standard = VPhoneLaunchpadSlimming()
- // Apple Account is always off; every other default is the CLI's own.
- precondition(standard.arguments == ["--accounts-off"], "The defaults pass only --accounts-off: \(standard.arguments)")
- precondition(standard.setupArguments == ["--accounts-off"], "Setup takes the defaults too")
+ // Apple Account is always off and the system apps stay; every other
+ // default is the CLI's own.
+ precondition(standard.arguments == ["--accounts-off", "--remove-apps", "off"], "The defaults: \(standard.arguments)")
+ precondition(standard.setupArguments == ["--accounts-off", "--remove-apps", "off"], "Setup takes the defaults too")
precondition(standard.trimArguments == ["--tier", "standard"], "Standard trim: \(standard.trimArguments ?? [])")
- precondition(standard.removedApps.count == 10, "Ten apps go by default")
- precondition(!standard.removedApps.contains("com.apple.camera") && !standard.removedApps.contains("com.apple.mobilephone"),
+ precondition(standard.removedApps.isEmpty, "No app goes by default")
+ var apps = VPhoneLaunchpadSlimming()
+ apps.removesApps = true
+ precondition(apps.arguments == ["--accounts-off"] && apps.removedApps.count == 10, "Ten apps go when removing")
+ precondition(!apps.removedApps.contains("com.apple.camera") && !apps.removedApps.contains("com.apple.camera") && !standard.removedApps.contains("com.apple.mobilephone"),
"Camera and Phone are never removed")
var off = VPhoneLaunchpadSlimming()
@@ -42,6 +46,7 @@ struct TemplatesTests {
precondition(off.removedApps.isEmpty, "Slim off removes no app")
var parts = VPhoneLaunchpadSlimming()
+ parts.removesApps = true
parts.trim = .conservative
parts.keptLanguages = "en, ja"
parts.trimsServices = false
@@ -57,6 +62,7 @@ struct TemplatesTests {
precondition(parts.trimArguments == ["--tier", "conservative"], "Conservative trim keeps no languages")
var languages = VPhoneLaunchpadSlimming()
+ languages.removesApps = true
languages.keptLanguages = " en , ja ,"
precondition(languages.arguments == ["--keep-languages", "en,ja", "--accounts-off"], "Languages: \(languages.arguments)")
precondition(languages.setupArguments == ["--accounts-off"], "Setup leaves the languages to the trim")
@@ -74,6 +80,7 @@ struct TemplatesTests {
precondition(noApps.arguments == ["--accounts-off", "--remove-apps", "off"], "Remove apps off ignores the kept list")
var none = VPhoneLaunchpadSlimming()
+ none.removesApps = true
none.trim = .none
precondition(none.arguments == ["--trim", "none", "--accounts-off"] && none.trimArguments == nil, "No trim step for tier none")
print("Slimming switch tests passed")
@@ -101,7 +108,7 @@ struct TemplatesTests {
"--cloudos-source", "https://example.invalid/cloudos",
"--device", "iPad16,1", "--preset", "standard", "--disk-size", "128",
"--block", "kernel-a", "--block", "kernel-b", "--allow", "dyld-x",
- "--service-profile", "none",
+ "--service-profile", "none", "--remove-apps", "off",
], "find: \(find)")
precondition(VPhoneLaunchpadTemplateCommands.trim("template-1a2b3c4d", slimming)
@@ -111,8 +118,8 @@ struct TemplatesTests {
precondition(VPhoneLaunchpadTemplateCommands.trim("t", untrimmed) == nil, "No trim command for tier none")
// Strict: an app the setup boot cannot remove fails the step.
precondition(VPhoneLaunchpadTemplateCommands.setup("template-1a2b3c4d", slimming)
- == ["vm", "template", "setup", "template-1a2b3c4d", "--strict", "--service-profile", "none"], "setup")
- precondition(VPhoneLaunchpadTemplateCommands.setup("t", VPhoneLaunchpadSlimming()) == ["vm", "template", "setup", "t", "--strict", "--accounts-off"],
+ == ["vm", "template", "setup", "template-1a2b3c4d", "--strict", "--service-profile", "none", "--remove-apps", "off"], "setup")
+ precondition(VPhoneLaunchpadTemplateCommands.setup("t", VPhoneLaunchpadSlimming()) == ["vm", "template", "setup", "t", "--strict", "--accounts-off", "--remove-apps", "off"],
"setup with the defaults")
// The adopt expects the id Find Template computed.
precondition(VPhoneLaunchpadTemplateCommands.adopt("template-1a2b3c4d", iphoneSource: "i", cloudOSSource: "c", expect: "2847ec2a3e3e")
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadApp.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadApp.swift
index 643769c4..2f2aef24 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadApp.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadApp.swift
@@ -39,6 +39,22 @@ struct VPhoneLaunchpadApp: App {
Button("Templates…") { model.present(.templates) }
}
}
+ // Now rather than on the next five-second tick: the machine list,
+ // then the templates, which also measures disk use again.
+ CommandGroup(before: .toolbar) {
+ Button("Refresh") {
+ Task {
+ await model.machines.refresh()
+ await model.machines.refreshTemplates()
+ }
+ }
+ .keyboardShortcut("r")
+ // Every command Launchpad ran, not one machine's: here rather
+ // than in a machine's menu.
+ Button("Recent Commands") { model.machineSheetRequest = .commands }
+ .keyboardShortcut("l", modifiers: [.command, .shift])
+ Divider()
+ }
CommandGroup(after: .appSettings) {
Button("Host Setup…") { model.present(.hostSetup) }
Button("Core Bundle…") { model.present(.coreBundle) }
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadSheet.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadSheet.swift
index 77345519..a9ef1d24 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadSheet.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadSheet.swift
@@ -123,10 +123,11 @@ struct VPhoneLaunchpadSheetPages<Page: Hashable, Labels: View>: View {
extension VPhoneLaunchpadSheet where Accessory == EmptyView {
init(
_ title: Text,
+ width: CGFloat = VPhoneLaunchpadSheetSize.width,
@ViewBuilder content: () -> Content,
@ViewBuilder actions: () -> Actions,
) {
- self.init(title, content: content, accessory: { EmptyView() }, actions: actions)
+ self.init(title, width: width, content: content, accessory: { EmptyView() }, actions: actions)
}
}
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Command/VPhoneLaunchpadCommandHistoryView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Command/VPhoneLaunchpadCommandHistoryView.swift
index ad354162..512bee24 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Command/VPhoneLaunchpadCommandHistoryView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Command/VPhoneLaunchpadCommandHistoryView.swift
@@ -14,7 +14,7 @@ struct VPhoneLaunchpadCommandHistoryView: View {
}
var body: some View {
- VPhoneLaunchpadSheet(Text("Recent Commands")) {
+ VPhoneLaunchpadSheet(Text("Recent Commands"), width: VPhoneLaunchpadSheetSize.wide) {
if entries.isEmpty {
ContentUnavailableView("Commands that Launchpad runs appear here.", systemImage: "terminal")
} else {
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Command/VPhoneLaunchpadCommandInfoButton.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Command/VPhoneLaunchpadCommandInfoButton.swift
index 0cd7ed95..469bbfab 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Command/VPhoneLaunchpadCommandInfoButton.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Command/VPhoneLaunchpadCommandInfoButton.swift
@@ -17,7 +17,9 @@ struct VPhoneLaunchpadCommandInfoButton: View {
.buttonStyle(.borderless)
.help("Show the command")
.accessibilityLabel(Text("Show the command"))
- .popover(isPresented: $isShown, arrowEdge: .trailing) {
+ // Below the button, or above it near the bottom of the screen: a
+ // side popover covers the rows next to it.
+ .popover(isPresented: $isShown, arrowEdge: .bottom) {
HStack(alignment: .firstTextBaseline, spacing: 8) {
Text(verbatim: command)
.font(.system(.callout, design: .monospaced))
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
index a46a6c7d..211f8c59 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
@@ -700,7 +700,8 @@ struct VPhoneLaunchpadControlCommands {
}
slimming.trimsServices = profile == "trimmed"
}
- slimming.removesApps = try onOff("remove-apps") ?? true
+ // Off by default as in New Machine; --keep-apps alone implies on.
+ slimming.removesApps = try onOff("remove-apps") ?? (request.option("keep-apps") != nil)
if let kept = request.option("keep-apps") {
let identifiers = Set(VPhoneLaunchpadSlimming.languageList(kept))
let known = Set(VPhoneLaunchpadSlimming.removableApps.map(\.id))
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSWCacheView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSWCacheView.swift
index a1cf3498..e078144b 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSWCacheView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSWCacheView.swift
@@ -39,19 +39,19 @@ struct VPhoneLaunchpadIPSWCacheView: View {
rows.filter { selection.contains($0.id) }
}
- /// Why the selection cannot be deleted, for the first row that cannot.
- private var blockedReason: String? {
- selected.lazy.compactMap(\.blockedReason).first
+ /// What deleting the selection would break, for the first row it would.
+ private var deletionWarning: String? {
+ selected.lazy.compactMap(\.deletionWarning).first
}
var body: some View {
- VPhoneLaunchpadSheet(Text("Downloaded Firmware")) {
+ VPhoneLaunchpadSheet(Text("Downloaded Firmware"), width: VPhoneLaunchpadSheetSize.wide) {
VStack(spacing: 0) {
list
.frame(maxWidth: .infinity, maxHeight: .infinity)
- if let reason = blockedReason {
+ if let warning = deletionWarning {
Divider()
- Label(reason, systemImage: "info.circle")
+ Label(warning, systemImage: "exclamationmark.triangle")
.font(.callout)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
@@ -61,8 +61,8 @@ struct VPhoneLaunchpadIPSWCacheView: View {
}
} accessory: {
Button("Delete…") { confirmDeletion() }
- .disabled(selected.isEmpty || blockedReason != nil || isDeleting)
- .help(blockedReason ?? String(localized: "Delete the selected IPSWs from the IPSW cache."))
+ .disabled(selected.isEmpty || isDeleting)
+ .help("Delete the selected IPSWs from the IPSW cache.")
} actions: {
Button("Done") { dismiss() }
.keyboardShortcut(.defaultAction)
@@ -127,6 +127,13 @@ struct VPhoneLaunchpadIPSWCacheView: View {
Text(verbatim: row.kindLabel)
}
.width(min: 60, ideal: 80)
+ TableColumn("Device", value: \.devices) { row in
+ Text(verbatim: row.devices)
+ .lineLimit(1)
+ .truncationMode(.tail)
+ .help(row.devices)
+ }
+ .width(min: 70, ideal: 110)
TableColumn("Size", value: \.size) { row in
Text(verbatim: Self.size(row.size))
.monospacedDigit()
@@ -271,22 +278,16 @@ struct VPhoneLaunchpadIPSWCacheView: View {
// MARK: - Deleting
- /// A selection with a row that cannot go says why at once; any other
- /// asks first.
+ /// Always asks first; the confirmation says what the deletion breaks.
private func confirmDeletion() {
let rows = selected
guard !rows.isEmpty, !isDeleting else {
return
}
- if let row = rows.first(where: { $0.blockedReason != nil }), let reason = row.blockedReason {
- actionError = VPhoneLaunchpadError(String(localized: "Unable to Delete \(row.title)"), detail: reason)
- } else {
- deletion = rows
- }
+ deletion = rows
}
- /// Checks each IPSW again at the moment of deletion: a creation may have
- /// started since the list was read. Stops at the first that fails.
+ /// Stops at the first IPSW that cannot be removed.
private func delete(_ rows: [VPhoneLaunchpadIPSWRow]) async {
guard !isDeleting, let scan else {
return
@@ -298,10 +299,6 @@ struct VPhoneLaunchpadIPSWCacheView: View {
continue
}
let failure = String(localized: "Unable to Delete \(row.title)")
- if let reason = VPhoneLaunchpadIPSWRows.deletionBlock(file, uses: uses(scan), isCreating: library.hasActiveCreation) {
- actionError = VPhoneLaunchpadError(failure, detail: reason)
- break
- }
do {
try await VPhoneLaunchpadIPSWCache.removeIPSW(file.url, cacheDirectories: scan.cacheDirectories)
} catch {
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSWRows.swift b/VPhoneLaunchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSWRows.swift
index 3e2f7283..0310b051 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSWRows.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSWRows.swift
@@ -9,11 +9,15 @@ nonisolated struct VPhoneLaunchpadIPSWRow: Identifiable, Hashable, Sendable {
var fileName: String
var kind: VPhoneLaunchpadIPSW.Kind
var kindLabel: String
+ /// The product types the IPSW restores, `iPhone17,3`, which tell apart
+ /// two IPSWs of one release.
+ var devices: String
var size: Int64
var usedBy: [String]
var isDownloading: Bool
- /// Why the IPSW cannot be deleted now; nil when it can.
- var blockedReason: String?
+ /// What deleting the IPSW now would break; nil when nothing. Deletion
+ /// goes ahead either way, after the confirmation repeats it.
+ var deletionWarning: String?
}
// MARK: - Catalog names
@@ -112,12 +116,13 @@ nonisolated enum VPhoneLaunchpadIPSWRows {
fileName: file.name,
kind: kind,
kindLabel: kindLabel(kind),
+ devices: facts?.productTypes.joined(separator: ", ") ?? "",
size: file.size,
usedBy: uses.filter { $0.uses(file) }.map { use in
use.isCreating ? String(localized: "\(use.machine) (creating)") : use.machine
},
isDownloading: file.isDownloading,
- blockedReason: deletionBlock(file, uses: uses, isCreating: isCreating),
+ deletionWarning: deletionWarning(file, uses: uses, isCreating: isCreating),
)
}
.sorted { lhs, rhs in
@@ -159,12 +164,14 @@ nonisolated enum VPhoneLaunchpadIPSWRows {
// MARK: Deleting
- /// Why `file` cannot be deleted now, or nil. A restored machine no longer
- /// reads its IPSWs: Update Kernel and Update Guest Environment work from
- /// the machine folder. So only a creation that has not finished holds
- /// one, since a retry reads its sources again. A partial file is a
- /// download, and only a creation under way downloads (`isCreating`).
- static func deletionBlock(
+ /// What deleting `file` now would break, or nil. A restored machine no
+ /// longer reads its IPSWs: Update Kernel and Update Guest Environment
+ /// work from the machine folder. So only a creation that has not
+ /// finished needs one, since a retry reads its sources again. A partial
+ /// file is a download, and only a creation under way downloads
+ /// (`isCreating`). None of this refuses the deletion: that creation
+ /// fails instead, and is retried or deleted.
+ static func deletionWarning(
_ file: VPhoneLaunchpadIPSWFile,
uses: [VPhoneLaunchpadIPSWUse],
isCreating: Bool,
@@ -182,17 +189,18 @@ nonisolated enum VPhoneLaunchpadIPSWRows {
}
/// The confirmation's text: what goes, which machines keep working, and
- /// what brings it back.
+ /// what brings it back, then what the deletion breaks.
static func deletionMessage(_ row: VPhoneLaunchpadIPSWRow) -> String {
+ let warning = row.deletionWarning.map { " \($0)" } ?? ""
if row.isDownloading {
- return String(localized: "The partial download of \(row.fileName) is deleted.")
+ return String(localized: "The partial download of \(row.fileName) is deleted.") + warning
}
let deleted = String(localized: "\(row.fileName) is deleted from the IPSW cache.")
let again = String(localized: "Creating a machine from this release downloads it again.")
guard !row.usedBy.isEmpty else {
- return "\(deleted) \(again)"
+ return "\(deleted) \(again)\(warning)"
}
let keep = String(localized: "\(row.usedBy.joined(separator: ", ")) keep working without it.")
- return "\(deleted) \(keep) \(again)"
+ return "\(deleted) \(keep) \(again)\(warning)"
}
}
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings b/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings
index 6fc7431b..179a8ee1 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings
@@ -1803,6 +1803,40 @@
}
}
},
+ "Machines created from it keep working: they share its blocks but do not need it." : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Machines created from it keep working: they share its blocks but do not need it."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "これから作成した仮想マシンは引き続き動作します。ブロックを共有していますが、テンプレートは不要です。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 템플릿으로 만든 가상 머신은 계속 동작합니다. 블록을 공유하지만 템플릿이 필요하지는 않습니다."
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Các máy ảo tạo từ mẫu này vẫn hoạt động: chúng dùng chung khối dữ liệu nhưng không cần đến mẫu."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "从它创建的虚拟机仍可正常使用:它们共享其数据块,但并不依赖它。"
+ }
+ }
+ }
+ },
"Machines from one template share its SEP root secret and Data volume keys. Turn this off for a machine that needs keys of its own." : {
"localizations" : {
"en" : {
@@ -3061,6 +3095,40 @@
}
}
},
+ "Terminate" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Terminate"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "強制終了"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "강제 종료"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Buộc dừng"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "终止"
+ }
+ }
+ }
+ },
"Template" : {
"localizations" : {
"en" : {
@@ -9579,6 +9647,40 @@
}
}
},
+ "Logs" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Logs"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ログ"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "로그"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nhật ký"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "日志"
+ }
+ }
+ }
+ },
"Machines" : {
"localizations" : {
"en" : {
@@ -9749,6 +9851,40 @@
}
}
},
+ "Maintenance" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Maintenance"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "メンテナンス"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "유지 관리"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bảo trì"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "维护"
+ }
+ }
+ }
+ },
"Memory" : {
"localizations" : {
"en" : {
@@ -16789,6 +16925,40 @@
"zh-Hans" : { "stringUnit" : { "state" : "translated", "value" : "如果在设置中授予的权限没有在这里显示,退出并重新打开 Launchpad" } }
}
},
+ "Refresh" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Refresh"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "更新"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "새로 고침"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Làm mới"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "刷新"
+ }
+ }
+ }
+ },
"Relaunch" : {
"localizations" : {
"en" : { "stringUnit" : { "state" : "translated", "value" : "Relaunch" } },
@@ -17140,6 +17310,40 @@
"zh-Hans" : { "stringUnit" : { "state" : "translated", "value" : "创建于 %@" } }
}
},
+ "Use Specified Firmware" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Use Specified Firmware"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "指定したファームウェアを使用"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "지정한 펌웨어 사용"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dùng firmware chỉ định"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "使用指定固件"
+ }
+ }
+ }
+ },
"Use Template" : {
"localizations" : {
"en" : { "stringUnit" : { "state" : "translated", "value" : "Use Template" } },
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadConsoleView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadConsoleView.swift
index cd305492..568532c6 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadConsoleView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadConsoleView.swift
@@ -7,7 +7,7 @@ struct VPhoneLaunchpadConsoleView: View {
@Environment(\.dismiss) private var dismiss
var body: some View {
- VPhoneLaunchpadSheet(Text(title)) {
+ VPhoneLaunchpadSheet(Text(title), width: VPhoneLaunchpadSheetSize.wide) {
VPhoneLaunchpadLogTerminal(url: url)
.frame(maxWidth: .infinity, minHeight: 560, maxHeight: .infinity)
.padding(.horizontal, 16)
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineActions.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineActions.swift
index e7f08e61..84dc2ebc 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineActions.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineActions.swift
@@ -34,30 +34,47 @@ struct VPhoneLaunchpadMachineActions: View {
let stopped = machines.filter { library.state(of: $0.path) == .stopped }
let running = machines.filter { library.state(of: $0.path) == .running }
let allStopped = stopped.count == machines.count
- Button("Settings…") { request(.settings(machines)) }
- .disabled(!allStopped)
- changeBundleButton
- Button("Export…") { request(.export(machines.map(\.path))) }
- .disabled(!allStopped)
- Button("Delete…", role: .destructive) { requestDeletion(machines.map(\.path)) }
- .disabled(!allStopped)
- Divider()
+ // The order of one machine's menu, with what applies to several.
Button("Start") { library.start(stopped) }
.disabled(stopped.isEmpty)
Button("Start Headless") { library.start(stopped, headless: true) }
.disabled(stopped.isEmpty)
Button("Stop") { library.stop(running) }
.disabled(running.isEmpty)
+ Button("Terminate") {
+ Task {
+ await withTaskGroup(of: Void.self) { group in
+ for machine in running {
+ group.addTask { await library.forceStop(machine.path) }
+ }
+ }
+ }
+ }
+ .disabled(running.isEmpty)
+ Divider()
+ Button("Settings…") { request(.settings(machines)) }
+ .disabled(!allStopped)
+ changeBundleButton
+ Divider()
+ Button("Export…") { request(.export(machines.map(\.path))) }
+ .disabled(!allStopped)
Divider()
Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting(machines.map(\.path.url))
}
+ Divider()
+ Button("Delete…", role: .destructive) { requestDeletion(machines.map(\.path)) }
+ .disabled(!allStopped)
} else if let machine = machines.first {
let state = library.state(of: machine.path)
let isStopped = state == .stopped
+ // Run, configure, the machine's files, maintenance and logs,
+ // then Delete.
switch state {
case .running:
Button("Stop") { library.stop([machine]) }
+ // For a guest that hangs or ignores Stop.
+ Button("Terminate") { Task { await library.forceStop(machine.path) } }
case .stopped:
Button("Start") { library.start([machine]) }
Button("Start Headless") { library.start([machine], headless: true) }
@@ -71,41 +88,45 @@ struct VPhoneLaunchpadMachineActions: View {
Button("Guest System…") { request(.guestSystem(machine.path)) }
.disabled(library.creation(for: machine.path)?.isRunning == true)
changeBundleButton
+ Divider()
Button("Rename…") { request(.rename(machine.path)) }
.disabled(!isStopped)
Button("Clone…") { request(.clone(machine.path)) }
.disabled(!isStopped)
- Button("Export…") { request(.export([machine.path])) }
- .disabled(!isStopped)
// Open while the machine runs too, to read the list; taking,
// reverting and deleting wait for it to stop.
Button("Snapshots…") { request(.snapshots(machine.path)) }
.disabled(library.creation(for: machine.path)?.isRunning == true)
- Button("Install Custom Firmware") {
- Task { await library.installCustomFirmware(machine.path) }
+ Button("Export…") { request(.export([machine.path])) }
+ .disabled(!isStopped)
+ Divider()
+ Menu("Maintenance") {
+ Button("Install Custom Firmware") {
+ Task { await library.installCustomFirmware(machine.path) }
+ }
+ // Only for an unfinished install: that is when the restore tree it
+ // reads is still there. A finished one removes it.
+ .disabled(!isStopped || machine.customFirmwareInstalled != false)
+ // The finished-install counterpart: redeploys the machine's own
+ // bundle's guest resources without the restore tree.
+ Button("Update Guest Environment") {
+ Task { await library.updateGuestEnvironment(machine.path) }
+ }
+ .disabled(!isStopped || machine.restoreInfo == nil || machine.customFirmwareInstalled == false)
}
- // Only for an unfinished install: that is when the restore tree it
- // reads is still there. A finished one removes it.
- .disabled(!isStopped || machine.customFirmwareInstalled != false)
- // The finished-install counterpart: redeploys the machine's own
- // bundle's guest resources without the restore tree.
- Button("Update Guest Environment") {
- Task { await library.updateGuestEnvironment(machine.path) }
+ Menu("Logs") {
+ Button("Open Console") { request(.console(machine.path)) }
+ Button("Show Console Log") {
+ NSWorkspace.shared.open(VPhoneLaunchpadMachineLibrary.consoleLog(machine.path))
+ }
+ Button("Show Patch Log") {
+ NSWorkspace.shared.open(VPhoneLaunchpadMachineLibrary.consoleLog(machine.path, suffix: "-patch"))
+ }
+ .disabled(!FileManager.default.fileExists(atPath: VPhoneLaunchpadMachineLibrary.consoleLog(machine.path, suffix: "-patch").path))
}
- .disabled(!isStopped || machine.restoreInfo == nil || machine.customFirmwareInstalled == false)
- Divider()
Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting([machine.path.url])
}
- Button("Open Console") { request(.console(machine.path)) }
- Button("Recent Commands") { request(.commands) }
- Button("Show Console Log") {
- NSWorkspace.shared.open(VPhoneLaunchpadMachineLibrary.consoleLog(machine.path))
- }
- Button("Show Patch Log") {
- NSWorkspace.shared.open(VPhoneLaunchpadMachineLibrary.consoleLog(machine.path, suffix: "-patch"))
- }
- .disabled(!FileManager.default.fileExists(atPath: VPhoneLaunchpadMachineLibrary.consoleLog(machine.path, suffix: "-patch").path))
Divider()
Button("Delete…", role: .destructive) { requestDeletion([machine.path]) }
.disabled(!isStopped)
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift
index 38c5b1f0..3127d939 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift
@@ -107,19 +107,29 @@ struct VPhoneLaunchpadMachineInspector: View {
var body: some View {
Form {
Section {
- if let creation = library.creation(for: machine.path) {
+ let creation = library.creation(for: machine.path)
+ if let creation {
creationSummary(creation)
}
- LabeledContent("State") {
- VPhoneLaunchpadMachineStateLabel(
- state: library.state(of: machine.path),
- progress: library.progress(of: machine.path),
- isDamaged: library.isDamaged(machine.path),
- )
+ // A running creation's summary already says what is going on.
+ if creation?.isRunning != true {
+ LabeledContent("State") {
+ VPhoneLaunchpadMachineStateLabel(
+ state: library.state(of: machine.path),
+ progress: library.progress(of: machine.path),
+ isDamaged: library.isDamaged(machine.path),
+ )
+ }
}
if let started = library.startedAt[machine.path] {
LabeledContent("Started", value: started.formatted(date: .omitted, time: .shortened))
}
+ } header: {
+ Text(machine.name)
+ .font(.headline)
+ } footer: {
+ // Under the card rather than in it: they act on the whole
+ // inspector, not on a row.
HStack {
Picker("Page", selection: $page) {
Text("General").tag(Page.general)
@@ -128,13 +138,13 @@ struct VPhoneLaunchpadMachineInspector: View {
}
.pickerStyle(.segmented)
.labelsHidden()
+ .fixedSize()
Spacer()
Button("Open Console") { onOpenConsole(machine.path) }
.fixedSize()
}
- } header: {
- Text(machine.name)
- .font(.headline)
+ .foregroundStyle(.primary)
+ .padding(.top, 4)
}
switch page {
@@ -144,6 +154,9 @@ struct VPhoneLaunchpadMachineInspector: View {
}
}
.formStyle(.grouped)
+ // The machine name sits under the toolbar, level with the table's
+ // header, without the grouped form's top margin above it.
+ .contentMargins(.top, 0, for: .scrollContent)
.task(id: patchReadKey) {
await loadPatches()
}
@@ -553,7 +566,7 @@ struct VPhoneLaunchpadMachineInspector: View {
}
} label: {
if creation.isRunning {
- Label { Text("Creating: \(creation.current?.title ?? "")") } icon: { VPhoneLaunchpadStatusIcon(status: .running) }
+ Label { Text(verbatim: creation.current?.title ?? "") } icon: { VPhoneLaunchpadStatusIcon(status: .running) }
} else if creation.isFinished {
Label { Text("Created") } icon: { VPhoneLaunchpadStatusIcon(status: .passed) }
} else {
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
index 0f24f28d..2404daf4 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
@@ -101,13 +101,12 @@ final class VPhoneLaunchpadMachineLibrary {
exports[machine]?.fraction ?? creation(for: machine)?.downloadFraction
}
+ /// A creation shows only its current step: the spinner says it is busy,
+ /// and the inspector says what is being created.
func state(of machine: Path) -> RunState {
- if let creation = creations[machine], creation.isRunning, let step = creation.current {
- return .busy(String(localized: "Creating: \(step.title)"))
- }
- // The temporary machine a template is built in.
+ // The machine, or the temporary machine a template is built in.
if let creation = creation(for: machine), creation.isRunning, let step = creation.current {
- return .busy(String(localized: "Building template: \(step.title)"))
+ return .busy(step.title)
}
if let activity = activities[machine] {
return .busy(activity)
@@ -833,6 +832,9 @@ final class VPhoneLaunchpadMachineLibrary {
["vm", "delete", machine.name, "--force"] + machine.libraryArguments,
anyBundle: true,
)
+ // A creation that stopped short goes with its machine; kept, it
+ // would still claim its IPSWs in Downloaded Firmware.
+ discardCreation(machine)
if let notice = VPhoneLaunchpadTemplateNotice.parse(result.lines, libraryRoot: machine.libraryRoot) {
templateNotice = notice
}
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
index ffdd638a..5a81ab9b 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
@@ -36,6 +36,9 @@ struct VPhoneLaunchpadMachinesView: View {
@Environment(VPhoneLaunchpadModel.self) private var model
@State private var sheet: Sheet?
+ /// The sheet to open once the current one has closed: New Machine's
+ /// creation progress, after New Machine itself is gone.
+ @State private var nextSheet: Sheet?
/// The machines the delete confirmation is for; empty when it is closed.
@State private var deletion: [MachinePath] = []
/// Empty keeps the order `vm list` returns; a header click replaces it.
@@ -128,7 +131,12 @@ struct VPhoneLaunchpadMachinesView: View {
sheet = note.object as? Sheet
}
#endif
- .sheet(item: $sheet) { sheet in
+ .sheet(item: $sheet, onDismiss: {
+ if let next = nextSheet {
+ nextSheet = nil
+ sheet = next
+ }
+ }) { sheet in
sheetContent(sheet)
.environment(model)
}
@@ -383,7 +391,8 @@ struct VPhoneLaunchpadMachinesView: View {
switch sheet {
case .newMachine:
VPhoneLaunchpadNewMachineView { path in
- self.sheet = .creation(path)
+ nextSheet = .creation(path)
+ self.sheet = nil
}
case let .creation(path):
if let creation = library.creation(for: path) {
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift
index 2d3e74ed..17efd067 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift
@@ -534,11 +534,7 @@ struct VPhoneLaunchpadNewMachineView: View {
private var firmwareSourceSection: some View {
Section {
- Picker("Source", selection: $usesCustomSources) {
- Text("Catalog").tag(false)
- Text("Custom IPSWs").tag(true)
- }
- .pickerStyle(.segmented)
+ Toggle("Use Specified Firmware", isOn: $usesCustomSources)
if usesCustomSources {
sourceField("iPhone IPSW", $iphoneSource)
@@ -785,7 +781,9 @@ struct VPhoneLaunchpadCreationView: View {
} header: {
Text("Template")
} footer: {
- Text(templateNote).foregroundStyle(.secondary)
+ if let templateNote {
+ Text(templateNote).foregroundStyle(.secondary)
+ }
}
}
Section {
@@ -842,15 +840,15 @@ struct VPhoneLaunchpadCreationView: View {
}
}
- private var templateNote: String {
+ /// Which template the machine came from, once that is known.
+ private var templateNote: String? {
if let id = creation.templateID, creation.plan.foundTemplate == true {
return String(localized: "Cloned from template \(id), which machines with these options share.")
}
if let id = creation.templateID, creation.builtTemplate {
return String(localized: "Saved as template \(id). The next machine with these options is cloned from it in seconds.")
}
- let build = creation.plan.buildName ?? ""
- return String(localized: "A missing template is built in \(build), set up once without a window, and saved under Templates.")
+ return nil
}
private func stepRow(_ step: Step) -> some View {
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swift
index 1c70e810..35c5c971 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swift
@@ -44,7 +44,8 @@ nonisolated struct VPhoneLaunchpadSlimming: Hashable, Sendable {
var keptLanguages = ""
/// The trimmed service profile; off is `--service-profile none`.
var trimsServices = true
- var removesApps = true
+ /// Off by default: the system apps stay unless New Machine picks them.
+ var removesApps = false
/// Apps of ``removableApps`` to keep.
var keptApps: Set<String> = []
/// Also turns off the Apple Account daemons, which counts only with the
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplatesView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplatesView.swift
index 7d82f271..3058094e 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplatesView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplatesView.swift
@@ -37,13 +37,13 @@ struct VPhoneLaunchpadTemplatesView: View {
}
var body: some View {
- VPhoneLaunchpadSheet(Text("Templates")) {
+ VPhoneLaunchpadSheet(Text("Templates"), width: VPhoneLaunchpadSheetSize.wide) {
VStack(spacing: 0) {
list
.frame(maxWidth: .infinity, maxHeight: .infinity)
- if selected.count == 1 {
+ if selected.count == 1, selected[0].stale {
Divider()
- detail(selected[0])
+ outdatedNote(selected[0])
}
ForEach(leftovers, id: \.build.path) { leftover in
Divider()
@@ -132,44 +132,50 @@ struct VPhoneLaunchpadTemplatesView: View {
}
}
+ /// One line per template. Machines do not depend on their template, so
+ /// no column looks them up.
private var table: some View {
Table(templates, selection: $selection, sortOrder: $sortOrder) {
- TableColumn("Template", value: \.key.device) { template in
- VStack(alignment: .leading, spacing: 2) {
- Text(verbatim: template.key.device)
- Text(verbatim: template.id)
- .font(.caption.monospaced())
- .foregroundStyle(.secondary)
- }
- .help(template.path)
+ TableColumn("Device", value: \.key.device) { template in
+ Text(verbatim: template.key.device)
+ }
+ .width(min: 70, ideal: 90)
+ TableColumn("Template", value: \.id) { template in
+ Text(verbatim: template.id)
+ .font(.body.monospaced())
+ .foregroundStyle(.secondary)
+ .help(origin(template))
}
- .width(min: 70, ideal: 84)
+ .width(min: 90, ideal: 110)
TableColumn("OS", value: \.key.iOSVersion) { template in
Text(verbatim: "\(template.key.osName) \(template.key.iOSVersion) (\(template.key.iOSBuild))")
.help(Text(verbatim: "cloudOS \(template.key.cloudOSVersion) (\(template.key.cloudOSBuild))"))
}
- .width(min: 100, ideal: 110)
+ .width(min: 110, ideal: 140)
TableColumn("Preset", value: \.key.patchPreset) { template in
- Text(verbatim: "\(template.key.patchPreset), \(template.key.diskSizeGB) GB")
+ Text(verbatim: template.key.patchPreset)
}
- .width(min: 70, ideal: 84)
- TableColumn("Size", value: \.allocatedBytes) { template in
- Text(verbatim: VPhoneLaunchpadDiskUsage.format(template.allocatedBytes))
+ .width(min: 60, ideal: 70)
+ TableColumn("Disk", value: \.key.diskSizeGB) { template in
+ Text(verbatim: "\(template.key.diskSizeGB) GB")
.monospacedDigit()
- .help(sizeHelp(template))
}
.width(min: 50, ideal: 56)
.alignment(.numeric)
- TableColumn("Machines", value: \.machinesOrder) { template in
- Text(verbatim: template.machines.isEmpty ? "—" : template.machines.joined(separator: ", "))
- .foregroundStyle(template.machines.isEmpty ? .secondary : .primary)
- .lineLimit(1)
- .truncationMode(.tail)
- .help(template.machines.joined(separator: ", "))
+ TableColumn("Slimming", value: \.key.slimming.summary) { template in
+ Text(verbatim: template.key.slimming.summary)
+ .help(slimmingHelp(template.key.slimming))
+ }
+ .width(min: 100, ideal: 170)
+ TableColumn("Size", value: \.allocatedBytes) { template in
+ Text(verbatim: VPhoneLaunchpadDiskUsage.format(template.allocatedBytes))
+ .monospacedDigit()
+ .help(sizeHelp(template))
}
.width(min: 50, ideal: 60)
+ .alignment(.numeric)
TableColumn("State", value: \.staleOrder) { template in
- // The icon alone: the detail below says what is outdated.
+ // The icon alone: the line below the table says what is outdated.
if template.stale {
VPhoneLaunchpadStatusIcon(status: .warning)
.help(String(localized: "Outdated") + "\n" + template.staleReasons.joined(separator: "\n"))
@@ -197,24 +203,26 @@ struct VPhoneLaunchpadTemplatesView: View {
.vphoneFocusedOnAppear()
}
- /// The selected template's details that do not fit a column.
- private func detail(_ template: VPhoneLaunchpadTemplate) -> some View {
- VStack(alignment: .leading, spacing: 4) {
- if template.stale {
- Label {
- Text("Outdated: \(template.staleReasons.joined(separator: "; ")). New machines get a new template; this one only takes space.")
- } icon: {
- Image(systemName: "exclamationmark.triangle.fill").foregroundStyle(.yellow)
- }
- }
- // Slimming and the date are here rather than in columns, which the
- // sheet has no room for.
- Text(verbatim: [template.key.slimming.summary, String(localized: "Created \(template.created.formatted(date: .abbreviated, time: .shortened))")].filter { !$0.isEmpty }.joined(separator: " · "))
- .help(slimmingHelp(template.key.slimming))
- if let sources = template.sources {
- Text("Built from \(URL(string: sources.iPhone)?.lastPathComponent ?? sources.iPhone) and cloudOS \(template.key.cloudOSVersion) (\(template.key.cloudOSBuild)).")
- }
- Text("Built with Core Bundle \(template.builtWithBundleVersion ?? "—"); every machine from it shares its SEP root secret and Data volume keys.")
+ /// What the identifier's tooltip says: when, from what and with which
+ /// bundle the template was built.
+ private func origin(_ template: VPhoneLaunchpadTemplate) -> String {
+ var lines = [String(localized: "Created \(template.created.formatted(date: .abbreviated, time: .shortened))")]
+ if let sources = template.sources {
+ lines.append(String(localized: "Built from \(URL(string: sources.iPhone)?.lastPathComponent ?? sources.iPhone) and cloudOS \(template.key.cloudOSVersion) (\(template.key.cloudOSBuild))."))
+ }
+ lines.append(String(localized: "Built with Core Bundle \(template.builtWithBundleVersion ?? "—"); every machine from it shares its SEP root secret and Data volume keys."))
+ lines.append(template.path)
+ return lines.joined(separator: "\n")
+ }
+
+ /// The one line under the table, for a selected outdated template.
+ private func outdatedNote(_ template: VPhoneLaunchpadTemplate) -> some View {
+ Label {
+ Text("Outdated: \(template.staleReasons.joined(separator: "; ")). New machines get a new template; this one only takes space.")
+ .lineLimit(1)
+ .truncationMode(.tail)
+ } icon: {
+ Image(systemName: "exclamationmark.triangle.fill").foregroundStyle(.yellow)
}
.font(.callout)
.foregroundStyle(.secondary)
@@ -246,11 +254,7 @@ struct VPhoneLaunchpadTemplatesView: View {
private func deletionMessage(_ template: VPhoneLaunchpadTemplate) -> String {
var parts: [String] = []
- if template.machines.isEmpty {
- parts.append(String(localized: "No machine was created from it."))
- } else {
- parts.append(String(localized: "\(template.machines.joined(separator: ", ")) keep working: they share its blocks but do not need it."))
- }
+ parts.append(String(localized: "Machines created from it keep working: they share its blocks but do not need it."))
if let exclusive = library.usage(of: template)?.exclusive {
parts.append(String(localized: "Deleting it frees about \(VPhoneLaunchpadDiskUsage.format(exclusive)), once no local Time Machine snapshot keeps those blocks; the blocks its machines share are freed once they change or are deleted."))
}
@@ -297,11 +301,6 @@ struct VPhoneLaunchpadTemplatesView: View {
}
extension VPhoneLaunchpadTemplate {
- /// The Machines column's order: unused templates first, then by the names.
- var machinesOrder: String {
- machines.joined(separator: ", ")
- }
-
/// The State column's order: current, then outdated.
var staleOrder: Int {
stale ? 1 : 0