vision-camera-code-scanner icon indicating copy to clipboard operation
vision-camera-code-scanner copied to clipboard

__scanCodes is not defined

Open chaudev opened this issue 3 years ago • 9 comments

Help me, please !!!

  • This is my "babel.config.js"

plugins: [ [ 'react-native-reanimated/plugin', { globals: ['__scanQRCodes'], }, ], ],

  • i tried:

project.ext.react = [ enableHermes: false ] project.ext.react = [ enableHermes: true ] yarn start --reset-cache

  • All are not working.

  • react-native: 0.70.1
  • vision-camera-code-scanner: 0.2.0
  • Mac M1
  • Android Device

chaudev avatar Oct 27 '22 03:10 chaudev

I resolved with that: https://github.com/rodgomesc/vision-camera-code-scanner/issues/79#issuecomment-1276041982

irodeanu avatar Oct 27 '22 09:10 irodeanu

Try adding one line to the file 'VisionCameraCodeScanner.m' as shown below.

@interface VISION_EXPORT_SWIFT_FRAME_PROCESSOR(scanCodes, VisionCameraCodeScanner) -(void)stub {} @end

hosijyun avatar Oct 30 '22 05:10 hosijyun

Try adding one line to the file 'VisionCameraCodeScanner.m' as shown below.

@interface VISION_EXPORT_SWIFT_FRAME_PROCESSOR(scanCodes, VisionCameraCodeScanner) -(void)stub {} @EnD

Where is the path of this file?

Moatezz avatar Nov 07 '22 01:11 Moatezz

One of the branches says that the fix was made in version 2.15.2, but I still have this error in android.

valery-lavrik avatar Nov 09 '22 07:11 valery-lavrik

I still have this error running from the example, running in ios.

Peege151 avatar Nov 17 '22 17:11 Peege151

In my babel.config.js I have

plugins: [[ 'react-native-reanimated/plugin', { globals: ['__scanCodes'] } ]]

I put '__scanCodes' instead of '__scanQRCodes' and it works for me

kaivamannam avatar Dec 07 '22 07:12 kaivamannam

the issue happens on Android with typescript enabled.

  • "react-native": "0.69.4"
  • "react-native-vision-camera": "2.15.2"
  • "vision-camera-code-scanner": "^0.2.0

Note: I updated react native to 0.70.6 and the issue is resolved

nhatnguyen95 avatar Dec 15 '22 04:12 nhatnguyen95

"react-native": "0.70.6" "react-native-vision-camera": "2.15.2" "vision-camera-code-scanner": "^0.2.0", "react-native-reanimated": "^2.13.0"

Hello Everyone I faced with the same issue and solved like this:

import { Camera, useCameraDevices, useFrameProcessor } from 'react-native-vision-camera';
import { BarcodeFormat, scanBarcodes, Barcode } from 'vision-camera-code-scanner';
import 'react-native-reanimated';
import { runOnJS } from 'react-native-reanimated';
import React, { useState } from 'react';
import { View, StyleSheet } from 'react-native';

const MyComponent = () => {
  const devices = useCameraDevices();
  const device = devices.back;
  const [barcodes, setBarcodes] = useState<Barcode[]>([]);

  const frameProcessor = useFrameProcessor((frame) => {
    'worklet';

    const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.ALL_FORMATS], { checkInverted: true });
    console.log(detectedBarcodes);
    runOnJS(setBarcodes)(detectedBarcodes);
  }, []);

  return (
    <View
      style={{
        flex: 1,
      }}>
      {device && (
        <Camera style={StyleSheet.absoluteFill} device={device} frameProcessor={frameProcessor} isActive={true} frameProcessorFps={60} />
      )}
    </View>
  );
};

export default MyComponent;

the point is I moved import reanimated into my component also changed FPS(frameProcessorFps) prop to 60 After that, I deleted node_modules, reinstalled and rebuild the app. So now it works fine for me

bb7hn avatar Dec 21 '22 14:12 bb7hn

This problem has bothered me for a long time, after update react-native-vision-camera to 2.15.2, this error disappear.

RenderCoder avatar Jan 09 '23 09:01 RenderCoder