Run a virtual iPhone on an Apple Silicon Mac.
Swift
Add Machine menu with shortcuts, view patches read-only, export directly
Lakr9341c9b99dc4
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadApp.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadApp.swiftindex 2f2aef24..83e54fe0 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadApp.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadApp.swift@@ -55,6 +55,17 @@ struct VPhoneLaunchpadApp: App {.keyboardShortcut("l", modifiers: [.command, .shift])Divider()}+ // The selected machines' actions, as the toolbar's Actions menu+ // has them, with shortcuts.+ CommandGroup(after: .pasteboard) {+ Divider()+ VPhoneLaunchpadMachineActions(machines: model.machines.selectedMachines, placement: .editMenu)+ .environment(model)+ }+ CommandMenu("Machine") {+ VPhoneLaunchpadMachineActions(machines: model.machines.selectedMachines, placement: .machineMenu)+ .environment(model)+ }CommandGroup(after: .appSettings) {Button("Host Setup…") { model.present(.hostSetup) }Button("Core Bundle…") { model.present(.coreBundle) }diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadPreview.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadPreview.swiftindex 9d4c0ff2..f7b8938d 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadPreview.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadPreview.swift@@ -81,7 +81,7 @@model.machines.applyPreview(creation: creation)if let machine = model.machines.selected {await standalone("05b-machine-inspector", suffix, size: NSSize(width: 380, height: 1500)) {- VPhoneLaunchpadMachineInspector(machine: machine, onShowProgress: { _ in }, onOpenConsole: { _ in })+ VPhoneLaunchpadMachineInspector(machine: machine, onShowProgress: { _ in }).environment(model)}}@@ -156,7 +156,6 @@await standalone("10d-take-snapshot", suffix, size: NSSize(width: 420, height: 330)) {VPhoneLaunchpadTakeSnapshotSheet(machine: labMachine, taken: Set(sampleSnapshots.map(\.name))) { _, _ in }}- await sheet(.export([labMachine]), "11-export", suffix)await sheet(.console(path("research-01")), "12-console", suffix)ipswSelection = ipswScan.ipsws[1].idawait panel(model, .ipswCache, "13-downloaded-ipsws", suffix)diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings b/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstringsindex 179a8ee1..10ebfa0f 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings@@ -10395,6 +10395,40 @@}}},+ "No Machine Selected" : {+ "localizations" : {+ "en" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "No Machine Selected"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "仮想マシンが選択されていません"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "선택한 가상 머신 없음"+ }+ },+ "vi" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Chưa chọn máy ảo"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未选择虚拟机"+ }+ }+ }+ },"No Selection" : {"localizations" : {"en" : {@@ -14817,6 +14851,40 @@}}},+ "View…" : {+ "localizations" : {+ "en" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "View…"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "表示…"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "보기…"+ }+ },+ "vi" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Xem…"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "查看…"+ }+ }+ }+ },"View Details" : {"localizations" : {"en" : {diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineActions.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineActions.swiftindex 84dc2ebc..d041922b 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineActions.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineActions.swift@@ -3,15 +3,28 @@ import SwiftUIimport UniformTypeIdentifiers/// The actions for one or more machines, shared by the toolbar's Actions-/// menu, the table's context menu and each machine's menu in the menu bar.-/// Several machines get the batch actions: one settings edit, export and-/// delete, which need every machine stopped, then start and stop.+/// menu, the table's context menu, each machine's menu in the menu bar and+/// the main menu, where they carry keyboard shortcuts: Machine holds most,+/// Edit holds Rename and Clone (Delete is Edit's own, from the table).+/// Several machines get the batch actions: start and stop, one settings+/// edit, export and delete, which need every machine stopped.////// Sheets and the delete confirmation belong to the machine list, so those/// items leave a request on the model that the list presents. The menu bar/// passes `willRequest` to open the window first.struct VPhoneLaunchpadMachineActions: View {+ enum Placement {+ /// Every action, without shortcuts: the Actions menu, the context+ /// menu and the menu bar.+ case full+ /// The main menu's Machine menu: all but Rename, Clone and Delete.+ case machineMenu+ /// The main menu's Edit menu: Rename and Clone.+ case editMenu+ }+let machines: [VPhoneLaunchpadMachine]+ var placement = Placement.fullvar willRequest: () -> Void = {}@Environment(VPhoneLaunchpadModel.self) private var model@@ -19,10 +32,21 @@ struct VPhoneLaunchpadMachineActions: View {model.machines}+ private var showsRunItems: Bool {+ placement != .editMenu+ }++ private var showsEditItems: Bool {+ placement != .machineMenu+ }+var body: some View {+ if machines.isEmpty, placement == .machineMenu {+ Text("No Machine Selected")+ }// Only while one of them is exporting or waiting to.let exporting = machines.filter { library.exports[$0.path] != nil }- if !exporting.isEmpty {+ if !exporting.isEmpty, showsRunItems {Button("Cancel Export") {for machine in exporting {library.cancelExport(machine.path)@@ -31,74 +55,111 @@ struct VPhoneLaunchpadMachineActions: View {Divider()}if machines.count > 1 {- 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- // 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) }- }- }- }+ if showsRunItems {+ multipleActions}+ } else if let machine = machines.first {+ singleActions(machine)+ }+ }++ // MARK: - Several machines++ @ViewBuilder+ private var multipleActions: some 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+ // The order of one machine's menu, with what applies to several.+ Button("Start") { library.start(stopped) }+ .disabled(stopped.isEmpty)+ .menuShortcut(.return, in: placement)+ Button("Start Headless") { library.start(stopped, headless: true) }+ .disabled(stopped.isEmpty)+ .menuShortcut(.return, [.command, .option], in: placement)+ Button("Stop") { library.stop(running) }.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))+ .menuShortcut(".", [.command, .shift], in: placement)+ 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)+ .menuShortcut("i", in: placement)+ changeBundleButton+ Divider()+ Button("Export…") { library.chooseExport(machines.map(\.path)) }+ .disabled(!allStopped)+ .menuShortcut("e", in: placement)+ Divider()+ Button("Show in Finder") {+ NSWorkspace.shared.activateFileViewerSelecting(machines.map(\.path.url))+ }+ .menuShortcut("r", [.command, .shift], in: placement)+ if placement == .full {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.+ }+ }++ // MARK: - One machine++ /// Run, configure, the machine's files, maintenance and logs, then+ /// Delete.+ @ViewBuilder+ private func singleActions(_ machine: VPhoneLaunchpadMachine) -> some View {+ let state = library.state(of: machine.path)+ let isStopped = state == .stopped+ if showsRunItems {switch state {case .running:Button("Stop") { library.stop([machine]) }+ .menuShortcut(".", [.command, .shift], in: placement)// For a guest that hangs or ignores Stop.Button("Terminate") { Task { await library.forceStop(machine.path) } }case .stopped:Button("Start") { library.start([machine]) }+ .menuShortcut(.return, in: placement)Button("Start Headless") { library.start([machine], headless: true) }+ .menuShortcut(.return, [.command, .option], in: placement)case let .busy(activity):Text(activity)}Divider()Button("Settings…") { request(.settings([machine])) }.disabled(!isStopped)+ .menuShortcut("i", in: placement)// It works on the running guest, and says so when it is not.Button("Guest System…") { request(.guestSystem(machine.path)) }.disabled(library.creation(for: machine.path)?.isRunning == true)changeBundleButtonDivider()+ }+ if showsEditItems {Button("Rename…") { request(.rename(machine.path)) }.disabled(!isStopped)Button("Clone…") { request(.clone(machine.path)) }.disabled(!isStopped)+ .menuShortcut("d", in: placement)+ }+ if showsRunItems {// 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("Export…") { request(.export([machine.path])) }+ .menuShortcut("s", [.command, .shift], in: placement)+ Button("Export…") { library.chooseExport([machine.path]) }.disabled(!isStopped)+ .menuShortcut("e", in: placement)Divider()Menu("Maintenance") {Button("Install Custom Firmware") {@@ -116,6 +177,7 @@ struct VPhoneLaunchpadMachineActions: View {}Menu("Logs") {Button("Open Console") { request(.console(machine.path)) }+ .menuShortcut("l", [.command, .option], in: placement)Button("Show Console Log") {NSWorkspace.shared.open(VPhoneLaunchpadMachineLibrary.consoleLog(machine.path))}@@ -127,6 +189,9 @@ struct VPhoneLaunchpadMachineActions: View {Button("Show in Finder") {NSWorkspace.shared.activateFileViewerSelecting([machine.path.url])}+ .menuShortcut("r", [.command, .shift], in: placement)+ }+ if placement == .full {Divider()Button("Delete…", role: .destructive) { requestDeletion([machine.path]) }.disabled(!isStopped)@@ -178,6 +243,42 @@ extension VPhoneLaunchpadMachineLibrary {}}+// MARK: - Export++extension VPhoneLaunchpadMachineLibrary {+ /// Export…: straight to the save panel, `<name>.vpea`; several machines+ /// go into one folder, one archive each. The restore IPSWs are never+ /// included: they belong to the IPSW cache, and a machine runs without+ /// them.+ func chooseExport(_ machines: [VPhoneLaunchpadMachinePath]) {+ if machines.count == 1 {+ let machine = machines[0]+ let panel = NSSavePanel()+ panel.title = String(localized: "Export \(machine.name)")+ panel.allowedContentTypes = [.vphoneExportedArchive]+ panel.nameFieldStringValue = Self.exportFileName(machine)+ panel.present { url in+ Task { await self.export([(machine, url)]) }+ }+ return+ }+ let panel = NSOpenPanel()+ panel.title = String(localized: "Export \(machines.count) Machines")+ panel.prompt = String(localized: "Export")+ panel.canChooseFiles = false+ panel.canChooseDirectories = true+ panel.canCreateDirectories = true+ panel.present { folder in+ let items = machines.map { ($0, folder.appendingPathComponent(Self.exportFileName($0))) }+ Task { await self.export(items) }+ }+ }++ private static func exportFileName(_ machine: VPhoneLaunchpadMachinePath) -> String {+ "\(machine.name).vpea"+ }+}+// MARK: - Importextension VPhoneLaunchpadMachineLibrary {@@ -213,3 +314,22 @@ extension VPhoneLaunchpadMachineLibrary {return true}}++// MARK: - Shortcuts++private extension View {+ /// A keyboard shortcut only in the main menu: the same items in the+ /// context menu and the menu bar would claim it twice.+ @ViewBuilder+ func menuShortcut(+ _ key: KeyEquivalent,+ _ modifiers: EventModifiers = .command,+ in placement: VPhoneLaunchpadMachineActions.Placement,+ ) -> some View {+ if placement == .full {+ self+ } else {+ keyboardShortcut(key, modifiers: modifiers)+ }+ }+}diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swiftindex 3127d939..7745b035 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineInspector.swift@@ -79,7 +79,6 @@ struct VPhoneLaunchpadMachineBundleLabel: View {struct VPhoneLaunchpadMachineInspector: View {let machine: VPhoneLaunchpadMachinelet onShowProgress: (VPhoneLaunchpadMachinePath) -> Void- let onOpenConsole: (VPhoneLaunchpadMachinePath) -> Void@Environment(VPhoneLaunchpadModel.self) private var model@State private var patchCatalog: VPhoneLaunchpadPatchCatalog?@State private var patchCatalogError: String?@@ -128,9 +127,10 @@ struct VPhoneLaunchpadMachineInspector: View {Text(machine.name).font(.headline)} footer: {- // Under the card rather than in it: they act on the whole- // inspector, not on a row.+ // Under the card rather than in it: it switches the whole+ // inspector, not a row. The console is in the Logs menu.HStack {+ Spacer()Picker("Page", selection: $page) {Text("General").tag(Page.general)Text("Hardware").tag(Page.hardware)@@ -140,8 +140,6 @@ struct VPhoneLaunchpadMachineInspector: View {.labelsHidden().fixedSize()Spacer()- Button("Open Console") { onOpenConsole(machine.path) }- .fixedSize()}.foregroundStyle(.primary).padding(.top, 4)@@ -166,12 +164,8 @@ struct VPhoneLaunchpadMachineInspector: View {initial: initial,bundleVersion: library.bundleVersion(for: path),machine: path,- ) { selection in- Task {- await library.setPatches(selection, for: path)- patchRevision += 1- }- }+ isReadOnly: true,+ ) { _ in }.environment(model)}}@@ -308,7 +302,7 @@ struct VPhoneLaunchpadMachineInspector: View {@ViewBuilderprivate var patchesPage: some View {if library.creation(for: machine.path)?.isRunning != true {- Section("Patches") {+ Section {if let catalog = patchCatalog, patchCatalogMachine == machine.path {LabeledContent("Preset",@@ -345,6 +339,20 @@ struct VPhoneLaunchpadMachineInspector: View {.fixedSize(horizontal: false, vertical: true)}}+ } else if let patchCatalogError {+ Text("Unavailable")+ .foregroundStyle(.secondary)+ .help(patchCatalogError)+ } else {+ ProgressView()+ .controlSize(.small)+ .frame(maxWidth: .infinity)+ }+ } header: {+ Text("Patches")+ } footer: {+ // Under the card rather than in it, as the page picker is.+ if let catalog = patchCatalog, patchCatalogMachine == machine.path {HStack {Spacer()if catalog.installed == true, catalog.pendingKernelPatches > 0 {@@ -371,16 +379,11 @@ struct VPhoneLaunchpadMachineInspector: View {? String(localized: "Updates the guest environment, which turns guest patches on or off to match this machine’s choice."): String(localized: "Stop the machine to apply its patch choice to the guest."))}- Button("Edit…") { editedPatches = catalog.selection }+ // A created machine's patches are shown, not changed.+ Button("View…") { editedPatches = catalog.selection }}- } else if let patchCatalogError {- Text("Unavailable")- .foregroundStyle(.secondary)- .help(patchCatalogError)- } else {- ProgressView()- .controlSize(.small)- .frame(maxWidth: .infinity)+ .foregroundStyle(.primary)+ .padding(.top, 4)}}} else {diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swiftindex 2404daf4..0d9cf52f 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift@@ -1112,7 +1112,7 @@ final class VPhoneLaunchpadMachineLibrary {/// Exports each machine to its destination file, one at a time: each/// export reads a whole disk image.- func export(_ items: [(machine: Path, destination: URL)], includeIPSW: Bool) async {+ func export(_ items: [(machine: Path, destination: URL)]) async {for item in items {exports[item.machine] = Export()}@@ -1122,7 +1122,7 @@ final class VPhoneLaunchpadMachineLibrary {continue}let task = Task {- await runExport(item.machine, to: item.destination, includeIPSW: includeIPSW)+ await runExport(item.machine, to: item.destination)}exports[item.machine]?.task = taskawait task.value@@ -1142,12 +1142,10 @@ final class VPhoneLaunchpadMachineLibrary {}}- private func runExport(_ machine: Path, to destination: URL, includeIPSW: Bool) async {- // zstd, the default: Launchpad does not offer xz.- var arguments = ["vm", "export", machine.name, "--out", destination.path] + machine.libraryArguments- if includeIPSW {- arguments.append("--include-ipsw")- }+ private func runExport(_ machine: Path, to destination: URL) async {+ // zstd, the default: Launchpad does not offer xz. Never+ // --include-ipsw: the restore IPSWs stay in the IPSW cache.+ let arguments = ["vm", "export", machine.name, "--out", destination.path] + machine.libraryArgumentsawait perform(String(localized: "Exporting…"), on: machine, arguments) { [weak self] fraction inTask { @MainActor in self?.exports[machine]?.fraction = fraction }}diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineSheets.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineSheets.swiftindex 12de71d9..25eda249 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineSheets.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineSheets.swift@@ -524,80 +524,3 @@ extension UTType {/// folder compressed with zstd. Declared in Info.plist.static let vphoneExportedArchive = UTType(exportedAs: "com.vphone.exported-archive")}--/// One machine offers the archive options. Several are written with the-/// defaults, one `<name>.vpea` each, into a folder chosen once.-struct VPhoneLaunchpadExportView: View {- let machines: [VPhoneLaunchpadMachinePath]- @Environment(VPhoneLaunchpadModel.self) private var model- @Environment(\.dismiss) private var dismiss- @State private var includeIPSW = false-- private var title: Text {- machines.count == 1 ? Text("Export \(machines[0].name)") : Text("Export \(machines.count) Machines")- }-- var body: some View {- VPhoneLaunchpadSheet(title) {- Form {- if machines.count == 1 {- Section {- Toggle("Include the restore IPSW directory", isOn: $includeIPSW)- } footer: {- Text("Creates a .vpea archive.")- .foregroundStyle(.secondary)- }- } else {- Section {- ForEach(machines, id: \.self) { machine in- Text(verbatim: Self.fileName(machine))- }- } footer: {- Text("Creates a .vpea archive for each machine in the folder you choose.")- .foregroundStyle(.secondary)- }- }- }- .formStyle(.grouped)- } actions: {- Button("Cancel") { dismiss() }- .keyboardShortcut(.cancelAction)- Button("Choose Location…") { choose() }- .keyboardShortcut(.defaultAction)- }- .fixedSize(horizontal: false, vertical: true)- }-- private static func fileName(_ machine: VPhoneLaunchpadMachinePath) -> String {- "\(machine.name).vpea"- }-- private func choose() {- let library = model.machines- if machines.count == 1 {- let machine = machines[0]- let panel = NSSavePanel()- panel.title = String(localized: "Export \(machine.name)")- panel.allowedContentTypes = [.vphoneExportedArchive]- panel.nameFieldStringValue = Self.fileName(machine)- let includeIPSW = includeIPSW- panel.present { url in- Task { await library.export([(machine, url)], includeIPSW: includeIPSW) }- dismiss()- }- return- }- let panel = NSOpenPanel()- panel.title = String(localized: "Export \(machines.count) Machines")- panel.prompt = String(localized: "Export")- panel.canChooseFiles = false- panel.canChooseDirectories = true- panel.canCreateDirectories = true- let machines = machines- panel.present { folder in- let items = machines.map { ($0, folder.appendingPathComponent(Self.fileName($0))) }- Task { await library.export(items, includeIPSW: false) }- dismiss()- }- }-}diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swiftindex 5a81ab9b..6827a8ec 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift@@ -11,7 +11,6 @@ struct VPhoneLaunchpadMachinesView: View {case changeBundle([VPhoneLaunchpadMachine])case rename(MachinePath)case clone(MachinePath)- case export([MachinePath])case snapshots(MachinePath)case console(MachinePath)case guestSystem(MachinePath)@@ -25,7 +24,6 @@ struct VPhoneLaunchpadMachinesView: View {case let .changeBundle(machines): "bundle-\(machines.map(\.path.url.path).joined(separator: "|"))"case let .rename(machine): "rename-\(machine.url.path)"case let .clone(machine): "clone-\(machine.url.path)"- case let .export(machines): "export-\(machines.map(\.url.path).joined(separator: "|"))"case let .snapshots(machine): "snapshots-\(machine.url.path)"case let .console(machine): "console-\(machine.url.path)"case let .guestSystem(machine): "guest-system-\(machine.url.path)"@@ -91,7 +89,6 @@ struct VPhoneLaunchpadMachinesView: View {VPhoneLaunchpadMachineInspector(machine: machine,onShowProgress: { path in sheet = .creation(path) },- onOpenConsole: { path in sheet = .console(path) },)} else if library.selection.count > 1 {ContentUnavailableView("\(library.selection.count) Machines Selected", systemImage: "iphone")@@ -352,6 +349,13 @@ struct VPhoneLaunchpadMachinesView: View {} primaryAction: { paths inlibrary.start(library.machines.filter { paths.contains($0.path) && library.state(of: $0.path) == .stopped })}+ // Edit > Delete and the Delete key, for the stopped selection.+ .onDeleteCommand {+ let paths = library.selectedMachines.map(\.path)+ if !paths.isEmpty, paths.allSatisfy({ library.state(of: $0) == .stopped }) {+ deletion = paths+ }+ }.focused($tableIsFocused).onAppear {tableIsFocused = true@@ -410,8 +414,6 @@ struct VPhoneLaunchpadMachinesView: View {VPhoneLaunchpadCloneSheet(machine: path) { newName, newIdentity inTask { await library.clone(path, as: newName, newIdentity: newIdentity) }}- case let .export(paths):- VPhoneLaunchpadExportView(machines: paths)case let .snapshots(path):VPhoneLaunchpadSnapshotsView(machine: path)case let .console(path):diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadPatchSettingsView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadPatchSettingsView.swiftindex 837d5b72..8f2519ee 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadPatchSettingsView.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadPatchSettingsView.swift@@ -27,6 +27,9 @@ struct VPhoneLaunchpadPatchSettingsView: View {/// Hands the edited choice back; New Machine holds it until the VM exists,/// the inspector saves it to the machine.let onSave: (VPhoneLaunchpadPatchSelection) -> Void+ /// The inspector shows a created machine's choice without changing it:+ /// its boot chain was patched when it was restored.+ let isReadOnly: Bool@Environment(VPhoneLaunchpadModel.self) private var model@Environment(\.dismiss) private var dismiss@@ -50,11 +53,13 @@ struct VPhoneLaunchpadPatchSettingsView: View {initial: VPhoneLaunchpadPatchSelection,bundleVersion: String? = nil,machine: VPhoneLaunchpadMachinePath? = nil,+ isReadOnly: Bool = false,onSave: @escaping (VPhoneLaunchpadPatchSelection) -> Void,) {self.initial = initialself.bundleVersion = bundleVersionself.machine = machine+ self.isReadOnly = isReadOnlyself.onSave = onSave_selection = State(initialValue: initial)}@@ -82,11 +87,16 @@ struct VPhoneLaunchpadPatchSettingsView: View {.foregroundStyle(.secondary).lineLimit(2)} actions: {- Button("Cancel") { dismiss() }- .keyboardShortcut(.cancelAction)- Button("Done") { commit() }- .keyboardShortcut(.defaultAction)- .disabled(catalog == nil)+ if isReadOnly {+ Button("Done") { dismiss() }+ .keyboardShortcut(.defaultAction)+ } else {+ Button("Cancel") { dismiss() }+ .keyboardShortcut(.cancelAction)+ Button("Done") { commit() }+ .keyboardShortcut(.defaultAction)+ .disabled(catalog == nil)+ }}.frame(height: 680)// A hidden patch leaves the selection, so the detail pane reads only@@ -119,7 +129,7 @@ struct VPhoneLaunchpadPatchSettingsView: View {}}.fixedSize()- .disabled(catalog == nil || isLoading)+ .disabled(catalog == nil || isLoading || isReadOnly)if isLoading {ProgressView().controlSize(.small)}@@ -187,6 +197,7 @@ struct VPhoneLaunchpadPatchSettingsView: View {set: { selection.set(patch, on: $0) },)).labelsHidden()+ .disabled(isReadOnly)}.width(36)@@ -246,7 +257,9 @@ struct VPhoneLaunchpadPatchSettingsView: View {}.contextMenu(forSelectionType: String.self) { ids inButton("Turn On") { set(ids, on: true) }+ .disabled(isReadOnly)Button("Turn Off") { set(ids, on: false) }+ .disabled(isReadOnly)}.vphoneFocusedOnAppear()}