@@ -269,20 +269,20 @@ class BarcodeScannerPlugin: Plugin, AVCaptureMetadataOutputObjectsDelegate {
269269 scanFormats = [ AVMetadataObject . ObjectType] ( )
270270
271271 ( args. formats ?? [ ] ) . forEach { format in
272- if let formatValue = format. value {
273- scanFormats. append ( formatValue)
274- } else {
275- invoke. reject ( " Unsupported barcode format on this iOS version: \( format) " )
276- return
277- }
272+ if let formatValue = format. value {
273+ scanFormats. append ( formatValue)
274+ } else {
275+ invoke. reject ( " Unsupported barcode format on this iOS version: \( format) " )
276+ return
277+ }
278278 }
279279
280280 if scanFormats. isEmpty {
281- for supportedFormat in SupportedFormat . allCases {
282- if let formatValue = supportedFormat. value {
283- scanFormats. append ( formatValue)
284- }
281+ for supportedFormat in SupportedFormat . allCases {
282+ if let formatValue = supportedFormat. value {
283+ scanFormats. append ( formatValue)
285284 }
285+ }
286286 }
287287
288288 self . metaOutput!. metadataObjectTypes = self . scanFormats
@@ -305,6 +305,13 @@ class BarcodeScannerPlugin: Plugin, AVCaptureMetadataOutputObjectsDelegate {
305305 return
306306 }
307307
308+ // Check if camera is available on this platform (iOS simulator doesn't have cameras)
309+ let availableVideoDevices = discoverCaptureDevices ( )
310+ if availableVideoDevices. isEmpty {
311+ invoke. reject ( " No camera available on this device (e.g., iOS Simulator) " )
312+ return
313+ }
314+
308315 var iOS14min : Bool = false
309316 if #available( iOS 14 . 0 , * ) { iOS14min = true }
310317 if !iOS14min && self . getPermissionState ( ) != " granted " {
0 commit comments