Redth / ZXing.Net.Mobile

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen
MIT License
1.07k stars 703 forks source link

Forms Crashing on iOS #587

Closed edmckee closed 7 years ago

edmckee commented 7 years ago

Using Xamarin.Forms 2.5.235-pre-6 but same issue happened on Current stable releases.

Tried using on ZXing.Net.Mobile version 2.2.9 and 2.1.47 and same error occurs.

Here's the code, basically just the sample code.

`
public AboutViewModel() { Title = "Scanner"; ScanCommand = new Command(async () => await LaunchScanner()); } public ICommand ScanCommand { get; } public async Task LaunchScanner() {

if ANDROID

            // Initialize the scanner first so it can track the current context
            MobileBarcodeScanner.Initialize (Application);
        #endif
        var scanner = new ZXing.Mobile.MobileBarcodeScanner();
        var result = await scanner.Scan();
        if (result != null)
            Console.WriteLine("Scanned Barcode: " + result.Text);
        return true;
    }`

I've done the init in the AppDelegate.cs ZXing.Net.Mobile.Forms.iOS.Platform.Init();

here's the error

2017-07-13 07:39:15.526 scannertest.iOS[3204:1144101] Starting to scan... 2017-07-13 07:39:15.595 scannertest.iOS[3204:1144101] ZXingScannerView.Setup() took 55.127 ms. 2017-07-13 07:39:15.595 scannertest.iOS[3204:1144101] StartScanning 2017-07-13 07:39:15.620 scannertest.iOS[3204:1144125] critical: Native stacktrace:

2017-07-13 07:39:15.624 scannertest.iOS[3204:1144101] PERF: Alloc AVCaptureVideoPreviewLayer took 5.506 ms. 2017-07-13 07:39:15.626 scannertest.iOS[3204:1144125] critical: 0 libmonosgen-2.0.dylib 0x000000010389d43c mono_handle_native_crash + 224 2017-07-13 07:39:15.626 scannertest.iOS[3204:1144125] critical: 1 libsystem_platform.dylib 0x0000000191195348 _sigtramp + 52 2017-07-13 07:39:15.627 scannertest.iOS[3204:1144125] critical: 2 libsystem_kernel.dylib 0x00000001910ce49c + 100 2017-07-13 07:39:15.628 scannertest.iOS[3204:1144125] critical: 3 libsystem_kernel.dylib 0x00000001910ce4c8 system_set_sfi_window + 0 2017-07-13 07:39:15.628 scannertest.iOS[3204:1144125] critical: 4 TCC 0x0000000194342328 + 0 2017-07-13 07:39:15.629 scannertest.iOS[3204:1144125] critical: 5 TCC 0x0000000194342224 + 0 2017-07-13 07:39:15.629 scannertest.iOS[3204:1144125] critical: 6 TCC 0x0000000194345330 + 348 2017-07-13 07:39:15.629 scannertest.iOS[3204:1144125] critical: 7 libxpc.dylib 0x00000001911d6fcc + 80 2017-07-13 07:39:15.629 scannertest.iOS[3204:1144125] critical: 8 libxpc.dylib 0x00000001911d6f3c + 40 2017-07-13 07:39:15.629 scannertest.iOS[3204:1144125] critical: 9 libdispatch.dylib 0x0000000190f8e1bc + 16 2017-07-13 07:39:15.630 scannertest.iOS[3204:1144125] critical: 10 libdispatch.dylib 0x0000000190f9ca4c + 732 2017-07-13 07:39:15.630 scannertest.iOS[3204:1144125] critical: 11 libdispatch.dylib 0x0000000190f9e34c + 572 2017-07-13 07:39:15.630 scannertest.iOS[3204:1144125] critical: 12 libdispatch.dylib 0x0000000190f9e0ac + 124 2017-07-13 07:39:15.630 scannertest.iOS[3204:1144125] critical: 13 libsystem_pthread.dylib 0x00000001911972a0 _pthread_wqthread + 1288 2017-07-13 07:39:15.630 scannertest.iOS[3204:1144125] critical: 14 libsystem_pthread.dylib 0x0000000191196d8c start_wqthread + 4 2017-07-13 07:39:15.631 scannertest.iOS[3204:1144125] critical:

Got a SIGABRT while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.

adrianclaveri commented 7 years ago

Try adding camera permissions in your info.plist (NSCameraUsageDescription attribute)

edmckee commented 7 years ago

That worked. Great!

Sent from my iPhone

On Jul 13, 2017, at 4:34 PM, adrianclaveri notifications@github.com wrote:

Try adding camera permissions in your info.plist (NSCameraUsageDescription attribute)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.