Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Replace remaining user-visible string concatenation with interpolation

Lakr2331f22bfe5d5b0
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCommand.swift
index 02e8cf23..e9c1fe1d 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCommand.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCommand.swift
@@ -122,12 +122,14 @@ struct VPhoneVirtualMachineListCommand: ParsableCommand {
print("No VMs in \(library.root.path). Create one with vm create.")
} else {
for r in reports {
- var line =
- "\(r.name) \(r.cpuCount) CPU \(r.memoryMB) MB \(r.diskSizeBytes / (1024 * 1024 * 1024)) GB disk"
+ let diskGB = r.diskSizeBytes / (1024 * 1024 * 1024)
if let info = r.restoreInfo {
- line += " iOS \(info.ios.version) / cloudOS \(info.cloudOS.version)"
+ print(
+ "\(r.name) \(r.cpuCount) CPU \(r.memoryMB) MB \(diskGB) GB disk iOS \(info.ios.version) / cloudOS \(info.cloudOS.version)"
+ )
+ } else {
+ print("\(r.name) \(r.cpuCount) CPU \(r.memoryMB) MB \(diskGB) GB disk")
}
- print(line)
}
}
}
@@ -248,11 +250,10 @@ struct VPhoneVirtualMachineConfigCommand: ParsableCommand {
}
private func describeNetwork(_ net: VPhoneVirtualMachineManifest.NetworkConfig) -> String {
- var s = net.mode.rawValue
if net.mode == .bridged, let iface = net.bridgeInterface {
- s += "(\(iface))"
+ return "\(net.mode.rawValue)(\(iface))"
}
- return s
+ return net.mode.rawValue
}
// MARK: - rename
diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Controls/VPhoneControlsModel.swift b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Controls/VPhoneControlsModel.swift
index c800c1b2..cd820f02 100644
--- a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Controls/VPhoneControlsModel.swift
+++ b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Controls/VPhoneControlsModel.swift
@@ -399,7 +399,7 @@ final class VPhoneControlsModel {
static func guestMessage(_ error: Error) -> String {
if case let VPhoneGuestControl.ControlError.guestError(message) = error, !message.isEmpty {
let sentence = message.prefix(1).uppercased() + message.dropFirst()
- return sentence.hasSuffix(".") ? sentence : sentence + "."
+ return sentence.hasSuffix(".") ? sentence : "\(sentence)."
}
return String(localized: "Check the connection, then try again.", bundle: VPhoneLocalization.bundle)
}
diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/DeviceInfo/VPhoneDeviceInfoModel.swift b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/DeviceInfo/VPhoneDeviceInfoModel.swift
index b64cdd85..3902df17 100644
--- a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/DeviceInfo/VPhoneDeviceInfoModel.swift
+++ b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/DeviceInfo/VPhoneDeviceInfoModel.swift
@@ -252,9 +252,11 @@ final class VPhoneDeviceInfoModel {
scale = "\(Self.number(factor))×"
}
}
- var orientation = rotation.string("name") ?? "—"
- if let degrees = rotation.int("degrees") {
- orientation += " (\(degrees)°)"
+ let orientationName = rotation.string("name") ?? "—"
+ let orientation = if let degrees = rotation.int("degrees") {
+ "\(orientationName) (\(degrees)°)"
+ } else {
+ orientationName
}
let rotationLocked = rotation.bool("locked")
return VPhoneDeviceInfoSection(kind: .display, title: Self.text("Display"), rows: [
diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Services/VPhoneServiceRow.swift b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Services/VPhoneServiceRow.swift
index ebe154ed..d4f3c077 100644
--- a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Services/VPhoneServiceRow.swift
+++ b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Services/VPhoneServiceRow.swift
@@ -130,7 +130,7 @@ struct VPhoneServiceExit {
return String((status >> 8) & 0xFF)
}
if signal != 0x7F {
- return Self.signalName(signal) + (status & 0x80 != 0 ? "+core" : "")
+ return status & 0x80 != 0 ? "\(Self.signalName(signal))+core" : Self.signalName(signal)
}
return String(status)
}
diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Services/VPhoneServicesView.swift b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Services/VPhoneServicesView.swift
index 7273b842..ec90090f 100644
--- a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Services/VPhoneServicesView.swift
+++ b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/Panels/Services/VPhoneServicesView.swift
@@ -234,7 +234,7 @@ struct VPhoneServicesView: View {
Button {
model.request(.signal(signal), on: row.label)
} label: {
- Text(verbatim: signal.title + "…")
+ Text(verbatim: "\(signal.title)…")
}
}
}