react-native-qrcode-scanner
react-native-qrcode-scanner copied to clipboard
For IOS getting ERROR TypeError: null is not an object (evaluating 'NativeModule.requestPermission'
What's happening?
For Android its working properly during IOS scan getting the error as ERROR TypeError: null is not an object (evaluating 'NativeModule.requestPermission' but i have installed by following the steps.
Please help me fix the issue or suggest the changes required.
How can it be reproduced?
If we try to use the qr code scanner code in render its getting the above error but with the same code its working in Android
<QRCodeScanner
onRead={this.barcodeReceived.bind(this)}
style={{flex: 1}}
cameraStyle={{height: Dimensions.get('window').height}}
showMarker={false}
fadeIn={false}
reactivate={true}
cameraType={"back"}
/>
Build details
"react": "17.0.2", "react-native": "0.66.4", "react-native-permissions": "^3.6.1", "react-native-qrcode-scanner": "^1.2.1",
try this one: react-native-permissions You will also need to install react-native-permissions to handle camera related permissions
npm install react-native-permissions --save react-native link react-native-permissions For iOS, as part of the react-native-permissions setup you will need to add the following code to your Podfile
permissions_path = '../node_modules/react-native-permissions/ios' pod 'Permission-Camera', :path => "#{permissions_path}/Camera" You may also need to reset your simulator data after adding those permissions Device -> Erase All Content and Settings...
This will help you https://www.youtube.com/watch?v=sE0MEyFA7E4&list=PLQhQEGkwKZUrempLnmxjt7ZCZJu1W3p2i&index=10
After spending two days debugging react-native-permissions
, I found the issue is with react-native-qrcode-scanner
.
It has "react-native-permissions": "^2.0.2"
in it's dependencies but the current version is "react-native-permissions": "^3.8.0"
.
This version of react-native-permissions (3.8.0)
has breaking changes.
Quick fix
- Install
react-native-permissions
. - Most importantly, remember to add
"reactNativePermissionsIOS": ["Camera"]
and"postinstall": "react-native setup-ios-permissions && pod-install"
to yourpackage.json
. - Run
npm install
. - Delete
node_modules/react-native-qrcode-scanner/node_modules/react-native-permissions
because it installs the deprecated2.0.2
. (You'll need to do this each time you clear your node_modules). - Your QR code scanner should be working again 🥳.
The postinstall
goes in the scripts
section of your package.json
.
You'll also need "pod-install": "0.1.38"
.
If you still have issues, delete your node_modules
, package.lock
and run pod deintegrate
. Then retry the steps.
PR Options
I can create a PR to fix this issue. We have two options:
- Take out the
react-native-permissions
dependency and update the readMe so everyone knows to install the dependency themselves and set it up properly. - Update the dependency and add the necessary steps. (
reactNativePermissionsIOS
andpostinstall
).
Please react with 👍
for option 1 and 🚀
for option 2.
Seem to have this error even after following the above steps on ios
duplicate symbol 'OBJC_CLASS$_RNPermissionHandlerCamera' in
libPermission-Camera.a(RNPermissionHandlerCamera.o) libRNPermissions.a(RNPermissionHandlerCamera.o)
❌ duplicate symbol 'OBJC_METACLASS$_RNPermissionHandlerCamera' in
libPermission-Camera.a(RNPermissionHandlerCamera.o) libRNPermissions.a(RNPermissionHandlerCamera.o)
❌ ld: 2 duplicate symbols for architecture x86_64
❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)
Seem to have this error even after following the above steps on ios
duplicate symbol 'OBJC_CLASS$_RNPermissionHandlerCamera' in
libPermission-Camera.a(RNPermissionHandlerCamera.o) libRNPermissions.a(RNPermissionHandlerCamera.o)
❌ duplicate symbol 'OBJC_METACLASS$_RNPermissionHandlerCamera' in
libPermission-Camera.a(RNPermissionHandlerCamera.o) libRNPermissions.a(RNPermissionHandlerCamera.o)
❌ ld: 2 duplicate symbols for architecture x86_64
❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)
Did you take out the prior react-native-permissions
installation steps from your podfile
?
In the past, you had to add the pods being used by react-native-permissions
to your podfile
. That's no longer needed.
Seem to have this error even after following the above steps on ios duplicate symbol 'OBJC_CLASS$_RNPermissionHandlerCamera' in
libPermission-Camera.a(RNPermissionHandlerCamera.o) libRNPermissions.a(RNPermissionHandlerCamera.o)
❌ duplicate symbol 'OBJC_METACLASS$_RNPermissionHandlerCamera' in
libPermission-Camera.a(RNPermissionHandlerCamera.o) libRNPermissions.a(RNPermissionHandlerCamera.o)
❌ ld: 2 duplicate symbols for architecture x86_64 ❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)
Did you take out the prior
react-native-permissions
installation steps from yourpodfile
?In the past, you had to add the pods being used by
react-native-permissions
to yourpodfile
. That's no longer needed.
i face same issue, follow your instruction, everything works now. You save my day, bro
@stanjhae Option 1 is better since reactNativePermissionsIOS
should be in user project package.json
, couldn't be set in the library package.json
.
The proper way to do it is to update this lib package.json
like this:
"peerDependencies": {
"react-native-permissions": "the-minimal-version-you-want-to-use"
},
"peerDependenciesMeta": {
"react-native-permissions": {
"optional": true
}
}