fix: Fix build on Xcode 14 (#2033)
* fix: Fix build on Xcode 14 * Format * Make CI run on `macOS-latest` * Nested if
This commit is contained in:
@@ -38,13 +38,15 @@ class CameraDevicesManager: RCTEventEmitter {
|
||||
|
||||
override func constantsToExport() -> [AnyHashable: Any]! {
|
||||
let devices = getDevicesJson()
|
||||
let preferredDevice: [String: Any]?
|
||||
if #available(iOS 17.0, *),
|
||||
let userPreferred = AVCaptureDevice.userPreferredCamera {
|
||||
preferredDevice = userPreferred.toDictionary()
|
||||
} else {
|
||||
preferredDevice = devices.first
|
||||
}
|
||||
let preferredDevice = devices.first
|
||||
|
||||
#if swift(>=5.9)
|
||||
if #available(iOS 17.0, *) {
|
||||
if let userPreferred = AVCaptureDevice.userPreferredCamera {
|
||||
preferredDevice = userPreferred.toDictionary()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return [
|
||||
"availableCameraDevices": devices,
|
||||
|
@@ -32,20 +32,26 @@ extension AVCaptureOutput {
|
||||
func setOrientation(_ orientation: Orientation) {
|
||||
// Set orientation for each connection
|
||||
connections.forEach { connection in
|
||||
if #available(iOS 17.0, *) {
|
||||
// Camera Sensors are always in landscape rotation (90deg).
|
||||
// We are setting the target rotation here, so we need to rotate by landscape once.
|
||||
let cameraOrientation = orientation.rotateBy(orientation: .landscapeLeft)
|
||||
let degrees = cameraOrientation.toDegrees()
|
||||
#if swift(>=5.9)
|
||||
if #available(iOS 17.0, *) {
|
||||
// Camera Sensors are always in landscape rotation (90deg).
|
||||
// We are setting the target rotation here, so we need to rotate by landscape once.
|
||||
let cameraOrientation = orientation.rotateBy(orientation: .landscapeLeft)
|
||||
let degrees = cameraOrientation.toDegrees()
|
||||
|
||||
if connection.isVideoRotationAngleSupported(degrees) {
|
||||
connection.videoRotationAngle = degrees
|
||||
if connection.isVideoRotationAngleSupported(degrees) {
|
||||
connection.videoRotationAngle = degrees
|
||||
}
|
||||
} else {
|
||||
if connection.isVideoOrientationSupported {
|
||||
connection.videoOrientation = orientation.toAVCaptureVideoOrientation()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#else
|
||||
if connection.isVideoOrientationSupported {
|
||||
connection.videoOrientation = orientation.toAVCaptureVideoOrientation()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user