CodeScanner icon indicating copy to clipboard operation
CodeScanner copied to clipboard

CodeScannerView is unable to read barcode picked from photos gallery.

Open theedov opened this issue 11 months ago • 4 comments

Getting error: .badOutput when picking a barcode from photos gallery. If I normally try to scan the same barcode, it works.

The operation couldn’t be completed. (CodeScanner.ScanError error 2.)

        CodeScannerView(
            codeTypes: [.upce, .ean8, .ean13, .code128, .code93, .code39],
            scanMode: .oncePerCode,
            shouldVibrateOnSuccess: false,
            isGalleryPresented: $showGallery,
            videoCaptureDevice: .systemPreferredCamera
        ) { response in
            switch response {
            case .success(let success):
                barcode = success.string
                image = success.image
            case .failure(let failure):
                print("+++ \(failure)")
                break
            }
        }

Image

Note: I tried to take a picture in many different angles.

theedov avatar Feb 16 '25 05:02 theedov

Hi! @theedov Could you figure it out?

Im facing the same issue. [error] The operation couldn’t be completed. (CodeScanner.ScanError error 2.)

brunnohofmann avatar Mar 25 '25 15:03 brunnohofmann

Hi! @theedov Could you figure it out?

Im facing the same issue. [error] The operation couldn’t be completed. (CodeScanner.ScanError error 2.)

Hey, no, I couldn't figure it out so I disabled the feature for now.

theedov avatar Mar 25 '25 19:03 theedov

Same here. Tested on QR, code128 and ean13 images. QR codes seemed to work fine, but none of my tested images with code128 and ean13 worked.

rutgerkra avatar Apr 28 '25 17:04 rutgerkra

Checked the source code and only a QR code detector is used, so that makes sense.

For manual picture selection I've gone a different route and added a PhotosPicker combined with VisionKit in my app.

rutgerkra avatar Apr 28 '25 19:04 rutgerkra