twostraws / CodeScanner

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
MIT License
1.02k stars 293 forks source link

README issue and crash #8

Closed kenji21 closed 4 years ago

kenji21 commented 4 years ago

There is CodeScanner( instead of CodeScannerView( in the Readme ;-)

Added the view, but there is a crash at https://github.com/twostraws/CodeScanner/blob/master/Sources/CodeScanner/CodeScanner.swift#L180 :

let previewConnection = captureSession.connections[1]

why using the second connection instead of the first (and only) one ?

2020-04-30 10:46:56.804933+0200 myapp[16312:4694359] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x194be55f0 0x194907bcc 0x194ae2300 0x1a206f8c4 0x1a207312c 0x1001e8a44 0x1001e8bf0 0x194b41590 0x194b415d8 0x194b40930 0x194b40608 0x194abd3a4 0x194b3ff68 0x194e9f524 0x198c853f0 0x198436058 0x1988e4a38 0x198435f50 0x1984359a4 0x198435d7c 0x19843563c 0x198439ad8 0x198808dd4 0x1988fde7c 0x198439834 0x1988fdd78 0x19843969c 0x1982a8f2c 0x1982a7acc 0x1982a8c64 0x19882e6f4 0x199d5fc98 0x199d84274 0x199d697ec 0x199d841a8 0x100533730 0x100536bb0 0x199da8440 0x199da810c 0x199da8634 0x194b63b64 0x194b63abc 0x194b63244 0x194b5e274 0x194b5dc34 0x19eca738c 0x198c9022c 0x10019e010 0x1949e5800)
libc++abi.dylib: terminating with uncaught exception of type NSException
kenji21 commented 4 years ago

happened when adding the view in ContentView of a single view project, so presented when is "launching"

robswei commented 4 years ago

This issue is causing a lot of errors in my app when attempting to scan QR codes. When will this PR be merged?

damirstuhec commented 4 years ago

@rtweine2 that depends on @twostraws. 🙂 Until then, if you want, you can use my fork's master branch.

twostraws commented 4 years ago

This has been merged.