Describe the bug
On a fresh new react-native 0.60.0 project
I am able to get Auth.signUp, and Auth.confirmSignUp to work as expected. When I try Auth.SignIn, I get this error: TypeError: Cannot read property 'computeModPow' of undefined.
Attempted Solution 1: Automatically Linking
Based on this issue https://github.com/aws-amplify/amplify-js/issues/563, where the suggestion is to run react-native link amazon-cognito-identity-js. This however, with 0.60 provides the following error:
error Unknown dependency. Make sure that the package you are trying to link is already installed in your "node_modules" and present in your "package.json" dependencies.
Attempted Solution 2: Manually Linking
drag RNAWSCognito.xcodeproj, then link with library, but building then provides this error: node_modules/amazon-cognito-identity-js/ios/RNAWSCognito.h:4:9: 'React/RCTBridgeModule.h' file not found
Any help would be greatly appreciated!
To Reproduce
Steps to reproduce the behavior:
react-native init, ensure you are on latest 0.60.0 versionamplify init, then amplify add auth. Once configured, try signing up. Should work.Expected behavior
Auth.signIn(username, password) should sign the user in.
Smartphone (please complete the following information):
A (far from optimal) solution is to install amazon-cognito-identity-js as a dependency (even though it already is a dependency of aws-amplify), and then run react-native link amazon-cognito-identity-js.
It works, but a legitimate solution would be great :D
@VicFrolov If I try your solution I end up with a Linker Error when I try to build
duplicate symbol _OBJC_CLASS_$_JKBigInteger in:
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/JKBigInteger2/libJKBigInteger2.a(JKBigInteger.o)
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/libRNAWSCognito.a(JKBigInteger.o)
duplicate symbol _OBJC_METACLASS_$_JKBigInteger in:
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/JKBigInteger2/libJKBigInteger2.a(JKBigInteger.o)
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/libRNAWSCognito.a(JKBigInteger.o)
duplicate symbol _OBJC_IVAR_$_JKBigInteger.m_value in:
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/JKBigInteger2/libJKBigInteger2.a(JKBigInteger.o)
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/libRNAWSCognito.a(JKBigInteger.o)
duplicate symbol _OBJC_IVAR_$_JKBigDecimal.bigInteger in:
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/JKBigInteger2/libJKBigInteger2.a(JKBigDecimal.o)
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/libRNAWSCognito.a(JKBigDecimal.o)
duplicate symbol _OBJC_CLASS_$_JKBigDecimal in:
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/JKBigInteger2/libJKBigInteger2.a(JKBigDecimal.o)
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/libRNAWSCognito.a(JKBigDecimal.o)
duplicate symbol _OBJC_METACLASS_$_JKBigDecimal in:
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/JKBigInteger2/libJKBigInteger2.a(JKBigDecimal.o)
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/libRNAWSCognito.a(JKBigDecimal.o)
duplicate symbol _OBJC_IVAR_$_JKBigDecimal.figure in:
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/JKBigInteger2/libJKBigInteger2.a(JKBigDecimal.o)
/Users/brady/Library/Developer/Xcode/DerivedData/traduki-ekuctotjpfcwpphgyaufmdogypjm/Build/Products/Debug-iphonesimulator/libRNAWSCognito.a(JKBigDecimal.o)
ld: 7 duplicate symbols for architecture x86_64
@VicFrolov can you sign in if you do not have the react native debugger attached?
I get Cannot read property 'USER_ID_FOR_SRP' of undefined if the debugger is attached, but can successfully sign in when not attached.
Seeing the same as @owinter86
Hi, it seems you are using react native 0.60.0 but are also trying to do react-native link amazon-cognito-identity-js. However in 0.60.0 autolinking was introduced which replaces react-native link. You can read more about how to use autolinking here
Make sure to run react-native unlink first before trying pod install from the ios directory.
@Ashish5591 Seems like the package isn't ready for autolinking, aws-amplify-react-native uses cognito-identity-js as a depedency, but when running pod install within the ios folder it doesn't install the cognito-identity-js so you have to actually install cognito-identity-js as a dependency and then run pod install, but then when you run the application you get a warning stating
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
What worked for me is doing
hope this helps
@VicFrolov I ended up making a call out of this on our docs about this and the workaround. Please see the above PR that was merged. Closing issue as the workaround resolves this issue
What worked for me is doing
- yarn add amazon-cognito-identity-js or npm install amazon-cognito-identity-js
- cd ios
- pod install --repo-update
hope this helps
Sir, you deserve a 馃!
This is the error that I was having. Leaving it here for better future Google-ability:
TypeError: Cannot read property 'USER_ID_FOR_SRP' of undefined
I know this issue is marked as closed (and I have done the pod install steps, which fixes the issue durning normal usage), but has anyone found a solution to avoiding this error when also debugging with react-native-debugger? (https://github.com/jhen0409/react-native-debugger)
Or, less ideally, found another debugging tool that will allow viewing of network requests in the app?
I had same issue on RN v0.61.5, and I posted how I solved.
I have the same issue with the following packages:
"aws-amplify": "^3.1.1",
"aws-amplify-react-native": "^4.2.5",
"react": "16.13.1",
"react-native": "0.63.2",
Has anyone found a solution without installing install amazon-cognito-identity-js? Since I'm using React Native with auto linking + have the aws-amplify package, it feels like there are extra steps that are unnecessary.
Most helpful comment
What worked for me is doing
hope this helps