Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Format Launchpad sources

Lakr18964659b818
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadModel.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadModel.swift
index afb3a2b7..19eef205 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadModel.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Application/VPhoneLaunchpadModel.swift
@@ -53,7 +53,7 @@ final class VPhoneLaunchpadModel {
return
}
queuedPanel = next
- self.panel = nil
+ panel = nil
}
/// Called when a panel's sheet has closed.
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
index 22d022ed..b8022ef1 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
@@ -67,7 +67,7 @@ struct VPhoneLaunchpadControlCommands {
// MARK: - Status
private func status() -> [String: Any] {
- let helper: String = switch model.helper.state {
+ let helper = switch model.helper.state {
case .unknown: "unknown"
case .notInstalled: "not installed"
case let .outdated(installed, bundled): "outdated (\(installed), app has \(bundled))"
@@ -176,7 +176,7 @@ struct VPhoneLaunchpadControlCommands {
guard let version = progress.version else {
throw VPhoneLaunchpadError("The install did not report a version.")
}
- return report(try installed(version))
+ return try report(installed(version))
}
private func reportSteps(
@@ -257,7 +257,7 @@ struct VPhoneLaunchpadControlCommands {
private func report(_ machine: VPhoneLaunchpadMachine) -> [String: Any] {
let path = machine.path
- let state: String = switch library.state(of: path) {
+ let state = switch library.state(of: path) {
case .stopped: "stopped"
case .running: "running"
case let .busy(activity): "busy: \(activity)"
@@ -446,7 +446,7 @@ struct VPhoneLaunchpadControlCommands {
let pipeline: VPhoneLaunchpadCreationPipeline
if let from = request.option("from") {
- guard let step = VPhoneLaunchpadCreationPipeline.Step.allCases.first(where: { "\($0)" == from }) else {
+ guard let step = VPhoneLaunchpadCreationPipeline.Step.allCases.first(where: { from == "\($0)" }) else {
let steps = VPhoneLaunchpadCreationPipeline.Step.allCases.map { "\($0)" }.joined(separator: ", ")
throw VPhoneLaunchpadError("--from takes one of: \(steps).")
}
diff --git a/VPhoneLaunchpad/VPhoneLaunchpadCLI/main.swift b/VPhoneLaunchpad/VPhoneLaunchpadCLI/main.swift
index 501ea4ee..e5de1da8 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpadCLI/main.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpadCLI/main.swift
@@ -164,12 +164,14 @@ if words.isEmpty || ["help", "-h", "--help"].contains(words[0]) {
print(usage(), terminator: "")
exit(words.isEmpty ? 1 : 0)
}
+
let request = parse(words)
let fd = connectControl() ?? launchAndConnect()
guard var line = try? JSONEncoder().encode(request) else {
fail("unable to encode the request.")
}
+
line.append(0x0A)
guard VPhoneLaunchpadControl.write(line, to: fd) else {
fail("vphone-launchpad closed the connection.")
@@ -207,4 +209,5 @@ while true {
exit(0)
}
}
+
fail("vphone-launchpad closed the connection before the command finished.")