Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Show the creation log in its own sheet

Lakr2338a68d5989596
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadPreview.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadPreview.swift
index ecbe3ee2..a2d3dc6b 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadPreview.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadPreview.swift
@@ -83,6 +83,12 @@
await sheet(.newMachine, "07-new-machine", suffix)
await sheet(.creation("ios27-rc"), "08-creation-progress", suffix)
+ creation.applyPreview(failed: true)
+ await sheet(.creation("ios27-rc"), "08b-creation-failed", suffix)
+ creation.applyPreview()
+ await standalone("08c-creation-log", suffix, size: NSSize(width: 900, height: 560)) {
+ VPhoneLaunchpadConsoleView(title: "ios27-rc Creation Log", url: creation.logFile)
+ }
model.machines.selection = "frida-lab"
if let machine = model.machines.selected {
await sheet(.settings(machine), "09-machine-settings", suffix)
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadTerminal.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadTerminal.swift
index 6987308b..03345f3c 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadTerminal.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadTerminal.swift
@@ -5,7 +5,7 @@ import SwiftUI
// MARK: - Theme
/// The one terminal look for every console and log. The light palette is the
-/// project's; the dark side keeps the same ANSI colours on a dark ground.
+/// project's; the dark side keeps the same ANSI colours.
/// `TerminalSurfaceView` picks the side from the SwiftUI colour scheme.
enum VPhoneLaunchpadTerminalTheme {
static let configuration = TerminalConfiguration {
@@ -14,6 +14,8 @@ enum VPhoneLaunchpadTerminalTheme {
$0.withFontSize(10)
$0.withFontThicken(true)
$0.withCustom("window-padding-color", "extend")
+ // The default background is clear: the sheet or window shows through.
+ $0.withBackgroundOpacity(0)
}
static let theme = TerminalTheme(
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings b/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings
index c09c425c..0f948bce 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings
@@ -35,6 +35,40 @@
}
}
},
+ "%@ Creation Log" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ Creation Log"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ の作成ログ"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ 생성 로그"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nhật ký tạo %@"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ 创建日志"
+ }
+ }
+ }
+ },
"%@ could not be started." : {
"localizations" : {
"en" : {
@@ -2915,36 +2949,36 @@
}
}
},
- "Download firmware" : {
+ "Download and prepare firmware" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Download firmware"
+ "value" : "Download and prepare firmware"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "ファームウェアをダウンロード"
+ "value" : "ファームウェアをダウンロードして準備"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "펌웨어 다운로드"
+ "value" : "펌웨어 다운로드 및 준비"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Tải xuống firmware"
+ "value" : "Tải xuống và chuẩn bị firmware"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "下载固件"
+ "value" : "下载并准备固件"
}
}
}
@@ -4649,40 +4683,6 @@
}
}
},
- "Log" : {
- "localizations" : {
- "en" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Log"
- }
- },
- "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" : {
@@ -5737,6 +5737,40 @@
}
}
},
+ "Open Log" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Open Log"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ログを開く"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "로그 열기"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mở nhật ký"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "打开日志"
+ }
+ }
+ }
+ },
"Open Settings" : {
"localizations" : {
"en" : {
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadConsoleView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadConsoleView.swift
index ec11c00b..60f50988 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadConsoleView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadConsoleView.swift
@@ -1,15 +1,16 @@
import SwiftUI
-/// A machine's console: the log `vm launch` writes, in a terminal that fills
-/// the sheet.
+/// A log in a terminal that fills the sheet: a machine's console, which
+/// `vm launch` writes, or a creation log.
struct VPhoneLaunchpadConsoleView: View {
- let name: String
+ let title: LocalizedStringKey
+ let url: URL
@Environment(\.dismiss) private var dismiss
var body: some View {
- VPhoneLaunchpadLogTerminal(url: VPhoneLaunchpadMachineLibrary.consoleLog(name))
+ VPhoneLaunchpadLogTerminal(url: url)
.frame(minWidth: 900, maxWidth: .infinity, minHeight: 560, maxHeight: .infinity)
- .navigationTitle("\(name) Console")
+ .navigationTitle(title)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Close") { dismiss() }
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadCreationPipeline.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadCreationPipeline.swift
index fee3f291..5263ec39 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadCreationPipeline.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadCreationPipeline.swift
@@ -49,7 +49,7 @@ final class VPhoneLaunchpadCreationPipeline {
var title: String {
switch self {
case .create: String(localized: "Create machine")
- case .prepare: String(localized: "Download firmware")
+ case .prepare: String(localized: "Download and prepare firmware")
case .patch: String(localized: "Patch boot chain")
case .bootDFU: String(localized: "Boot into DFU")
case .waitDFU: String(localized: "Wait for DFU")
@@ -431,7 +431,19 @@ final class VPhoneLaunchpadCreationPipeline {
#if DEBUG
extension VPhoneLaunchpadCreationPipeline {
- func applyPreview() {
+ /// Running the restore, or failed while preparing firmware.
+ func applyPreview(failed: Bool = false) {
+ statuses = [:]
+ durations = [:]
+ if failed {
+ statuses[.create] = .passed
+ durations[.create] = 0
+ statuses[.prepare] = .failed
+ durations[.prepare] = 6
+ current = nil
+ isRunning = false
+ return
+ }
let finished: [Step: TimeInterval] = [.create: 1, .prepare: 862, .patch: 48, .bootDFU: 6, .waitDFU: 3]
for (step, duration) in finished {
statuses[step] = .passed
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
index 1f96507b..f334cec0 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift
@@ -251,7 +251,7 @@ struct VPhoneLaunchpadMachinesView: View {
case let .export(name):
VPhoneLaunchpadExportView(name: name)
case let .console(name):
- VPhoneLaunchpadConsoleView(name: name)
+ VPhoneLaunchpadConsoleView(title: "\(name) Console", url: VPhoneLaunchpadMachineLibrary.consoleLog(name))
}
}
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift
index 943fb73c..70f37164 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift
@@ -215,10 +215,12 @@ struct VPhoneLaunchpadNewMachineView: View {
// MARK: - Pipeline
-/// The pipeline, which keeps running when this sheet closes.
+/// The pipeline, which keeps running when this sheet closes. A failure shows
+/// on its step; the log, which records why, opens in its own sheet.
struct VPhoneLaunchpadCreationView: View {
let creation: VPhoneLaunchpadCreationPipeline
@Environment(\.dismiss) private var dismiss
+ @State private var showsLog = false
var body: some View {
Form {
@@ -227,28 +229,24 @@ struct VPhoneLaunchpadCreationView: View {
stepRow(step)
}
} footer: {
- if let failure = creation.failure {
- VStack(alignment: .leading, spacing: 4) {
- Text(failure.message).foregroundStyle(.red)
- if let detail = failure.detail {
- Text(detail)
- .foregroundStyle(.secondary)
- .textSelection(.enabled)
- .lineLimit(8)
- }
- }
- } else if creation.isRunning {
+ if creation.isRunning {
Text("Creation continues if you close this window.").foregroundStyle(.secondary)
}
}
- Section("Log") {
- VPhoneLaunchpadLogTerminal(url: creation.logFile)
- .frame(minHeight: 200)
+ Section {
+ Button {
+ showsLog = true
+ } label: {
+ Label("Open Log", systemImage: "arrow.up.right")
+ }
}
}
.formStyle(.grouped)
.navigationTitle("Creating \(creation.options.name)")
.frame(width: 720, height: 640)
+ .sheet(isPresented: $showsLog) {
+ VPhoneLaunchpadConsoleView(title: "\(creation.options.name) Creation Log", url: creation.logFile)
+ }
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Close") { dismiss() }