Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Fix unsafeBitCast warning in screenshot CF type conversion

Lakra6ce50b4c0c9
diff --git a/sources/vphone-cli/VPhoneControl.swift b/sources/vphone-cli/VPhoneControl.swift
index 8e735fc8..c18641cb 100644
--- a/sources/vphone-cli/VPhoneControl.swift
+++ b/sources/vphone-cli/VPhoneControl.swift
@@ -126,7 +126,7 @@ class VPhoneControl {
case let .success(conn):
self?.connection = conn
self?.performHandshake(fd: conn.fileDescriptor)
- case let .failure(error):
+ case .failure:
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
self?.attemptConnect()
}
diff --git a/sources/vphone-cli/VPhoneScreenRecorder.swift b/sources/vphone-cli/VPhoneScreenRecorder.swift
index 39040f34..35042d35 100644
--- a/sources/vphone-cli/VPhoneScreenRecorder.swift
+++ b/sources/vphone-cli/VPhoneScreenRecorder.swift
@@ -286,9 +286,10 @@ class VPhoneScreenRecorder {
return nsImage.cgImage(forProposedRect: nil, context: nil, hints: nil)
}
- let cfObject = unsafeBitCast(imageObject, to: CFTypeRef.self)
+ let cfObject = imageObject as CFTypeRef
if CFGetTypeID(cfObject) == CGImage.typeID {
- return unsafeBitCast(cfObject, to: CGImage.self)
+ // CGImage is a CF type, not a Swift class — unsafeDowncast cannot be used here.
+ return (cfObject as! CGImage) // swiftlint:disable:this force_cast
}
return nil