Navaron Bracke

fix a build issue

@@ -133,7 +133,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -133,7 +133,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
133 } 133 }
134 134
135 /// Start scanning for barcodes 135 /// Start scanning for barcodes
136 - func start(barcodeScannerOptions: BarcodeScannerOptions?, returnImage: Bool, cameraPosition: AVCaptureDevice.Position, torch: Boolean, detectionSpeed: DetectionSpeed, completion: @escaping (MobileScannerStartParameters) -> ()) throws { 136 + func start(barcodeScannerOptions: BarcodeScannerOptions?, returnImage: Bool, cameraPosition: AVCaptureDevice.Position, torch: Bool, detectionSpeed: DetectionSpeed, completion: @escaping (MobileScannerStartParameters) -> ()) throws {
137 self.detectionSpeed = detectionSpeed 137 self.detectionSpeed = detectionSpeed
138 if (device != nil) { 138 if (device != nil) {
139 throw MobileScannerError.alreadyStarted 139 throw MobileScannerError.alreadyStarted
@@ -282,7 +282,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -282,7 +282,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
282 } 282 }
283 283
284 if (device.torchMode != torch) { 284 if (device.torchMode != torch) {
285 - device.lockForConfiguration() 285 + try device.lockForConfiguration()
286 device.torchMode = torch 286 device.torchMode = torch
287 device.unlockForConfiguration() 287 device.unlockForConfiguration()
288 } 288 }
@@ -277,7 +277,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -277,7 +277,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
277 // Turn on the torch if requested. 277 // Turn on the torch if requested.
278 if (torch) { 278 if (torch) {
279 do { 279 do {
280 - self.toggleTorchInternal(.on) 280 + try self.toggleTorchInternal(.on)
281 } catch { 281 } catch {
282 // If the torch could not be turned on, 282 // If the torch could not be turned on,
283 // continue the capture session. 283 // continue the capture session.
@@ -320,12 +320,18 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -320,12 +320,18 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
320 320
321 // TODO: this method should be removed when iOS and MacOS share their implementation. 321 // TODO: this method should be removed when iOS and MacOS share their implementation.
322 private func toggleTorchInternal(_ torch: AVCaptureDevice.TorchMode) throws { 322 private func toggleTorchInternal(_ torch: AVCaptureDevice.TorchMode) throws {
323 - if (device == nil || !device.hasTorch || !device.isTorchAvailable) { 323 + if (device == nil || !device.hasTorch) {
324 return 324 return
325 } 325 }
  326 +
  327 + if #available(macOS 15.0, *) {
  328 + if(!device.isTorchAvailable) {
  329 + return
  330 + }
  331 + }
326 332
327 if (device.torchMode != torch) { 333 if (device.torchMode != torch) {
328 - device.lockForConfiguration() 334 + try device.lockForConfiguration()
329 device.torchMode = torch 335 device.torchMode = torch
330 device.unlockForConfiguration() 336 device.unlockForConfiguration()
331 } 337 }