Run a virtual iPhone on an Apple Silicon Mac.
Swift
launchpad: Add Export Preset… to Patch Settings
zqxwceaa02955e2d2c
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadPatchSettingsView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadPatchSettingsView.swiftindex 87110030..7cdec3c6 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadPatchSettingsView.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadPatchSettingsView.swift@@ -1,4 +1,6 @@+import AppKitimport SwiftUI+import UniformTypeIdentifiers/// The patch editor: a preset, and a checkmark for every patch the bundle/// declares. New Machine opens it for a machine that does not exist yet, and@@ -47,6 +49,8 @@ struct VPhoneLaunchpadPatchSettingsView: View {@State private var confirmsBootEssential = false/// Why the preset file chosen with Other… could not be read.@State private var presetFileError: String?+ /// Why Export Preset… failed.+ @State private var exportError: String?/// What was on when the editor opened, so the status line can count what/// an edit to an existing machine changes. Taken from the first read.@State private var initiallyOn: Set<String>?@@ -89,6 +93,9 @@ struct VPhoneLaunchpadPatchSettingsView: View {.foregroundStyle(.secondary).lineLimit(2)} actions: {+ Button("Export Preset…") { chooseExport() }+ .disabled(catalog == nil || isLoading || !selection.hasOverrides)+ .help("Save the preset with these changes, to choose later with Other…")if isReadOnly {Button("Done") { dismiss() }.keyboardShortcut(.defaultAction)@@ -124,6 +131,14 @@ struct VPhoneLaunchpadPatchSettingsView: View {} message: {Text(verbatim: presetFileError ?? "")}+ .alert(+ "Unable to Export the Preset",+ isPresented: Binding(get: { exportError != nil }, set: { if !$0 { exportError = nil } }),+ ) {+ Button("OK") { exportError = nil }+ } message: {+ Text(verbatim: exportError ?? "")+ }.task { await load(preset: initial.presetArgument) }}@@ -406,6 +421,34 @@ struct VPhoneLaunchpadPatchSettingsView: View {}}+ /// Export Preset…: the preset with the boxes as they are now, saved or+ /// not, folded in by `fw export-preset`. The file's name is its identifier.+ private func chooseExport() {+ // With the machine named, a preset only it keeps a copy of resolves.+ let arguments = ["fw", "export-preset"] + (machine.map { [$0.name] } ?? [])+ + selection.setPatchesArguments + (machine?.libraryArguments ?? [])+ let panel = NSSavePanel()+ panel.title = String(localized: "Export Preset")+ panel.allowedContentTypes = [.propertyList]+ panel.nameFieldStringValue = "\(selection.preset)-modified.plist"+ panel.isExtensionHidden = false+ panel.present { url in+ Task { await export(arguments + ["--output", url.path]) }+ }+ }++ private func export(_ arguments: [String]) async {+ guard let commandLine = bundleVersion.map(model.bundles.commandLine(version:)) ?? model.bundles.commandLine() else {+ exportError = String(localized: "No Core Bundle version is in use. Choose a version in Core Bundle.")+ return+ }+ do {+ try await commandLine.runChecked(arguments)+ } catch {+ exportError = VPhoneLaunchpadError.message(for: error)+ }+ }+private func commit() {if essentialOff.isEmpty {finish()