EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 448 forks source link

ReferenceError: Can't find variable: TNSMLKitCameraView #1797

Closed michaelsmedley closed 3 years ago

michaelsmedley commented 3 years ago

Hi

I'm having trouble integrating the ML Kit Barcode reader into an app within a NativeScript-Vue app, the app is crashing with the above error message.

When I launch a page with the MLKitBarcodeScanner component, the app is crashing with an stack trace similar to the following:

*** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: TNSMLKitCameraView
 at 
file:///app/vendor.js:103726:44
at invoke(file:///app/vendor.js:14935:26)
at file:///app/vendor.js:14882:20
at UIApplicationMain([native code])
at run(file:///app/vendor.js:867:22)
at file:///app/vendor.js:125481:18
at file:///app/vendor.js:111332:15
at file:///app/bundle.js:27027:10
at ./main.js(file:///app/bundle.js:27031:34)
at __webpack_require__(file:///app/runtime.js:75:34)
at checkDeferredModules(file:///app/runtime.js:44:42)
at webpackJsonpCallback(file:///app/runtime.js:31:39)
at anonymous(file:///app/bundle.js:2:61)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([native code])
at [native code]
at promiseReactionJob([native code])
', reason: '(null)'
terminating with uncaught exception of type NSException

This is happening when running the app through XCode 12.4, connected to a real device after doing a tns build ios. For reference, this is happening when using nativescript-plugin-firebase@10.6.3 and tns-ios@6.5.2.

There's nothing particularly out-the-ordinary with the code:

main.js:

Vue.registerElement(
  "MLKitBarcodeScanner",
  () =>
    require("nativescript-plugin-firebase/mlkit/barcodescanning")
      .MLKitBarcodeScanner
);

QrScanner.vue

<template>
  <Page>
    <ActionBar title="QR Code Scanner" icon="">
      <NavigationButton
        icon="res://baseline_menu_white_24"
        @tap="onDrawerButtonTap"
      />
    </ActionBar>

    <MLKitBarcodeScanner
      width="260"
      height="380"
      :beep-on-scan="true"
      formats="QR_CODE"
      :prefer-front-camera="false"
      :support-Inverse-barcodes="false"
      :torch-on="torchOn"
      @scanResult="onTextRecognitionResult"
    >
    </MLKitBarcodeScanner>
  </Page>
</template>

Hopefully this is enough to help debug the issue. Of course if there's anything else I can provide to help then I will be more then happy to.

Any help will be much appreciated. Thanks all!

EDIT: If it helps this is my firebase.nativescript.json file:

{
    "using_ios": true,
    "using_android": true,
    "analytics": false,
    "firestore": false,
    "realtimedb": false,
    "authentication": false,
    "remote_config": false,
    "performance_monitoring": true,
    "external_push_client_only": false,
    "messaging": true,
    "in_app_messaging": false,
    "crashlytics": true,
    "storage": false,
    "functions": false,
    "facebook_auth": false,
    "google_auth": false,
    "admob": false,
    "dynamic_links": false,
    "ml_kit": true
}

Camera permissions are granted for the app as well. I can also supply the whole stack trace if it will help

michaelsmedley commented 3 years ago

OK, the issue is down to me not re-installing properly after updating my firebase.nativescript.json file.

I basically removed the plugin and this file, re-added the plugin and went through the installation steps and the plugin is working perfectly now, so going to close this issue.

Thanks again