问题
Background:
I'm using Firebase for my apps login. I am using the login via email address functionality. The error started after starting to use the new xCode beta and updating the code to Swift 3
You can see a prototype of the problem here: https://bitbucket.org/gilosborne/firebasetest
The error:
When I try to log in I get the error, "An error occurred while accessing the keychain".
I am not using Apple keychain in any way, I believe it is referring to the mentions of keychain here: https://firebase.google.com/docs/auth/ios/errors
When I enter the email address wrong i get the correct error saying the email address doesn't match. And creating a new account still works also. I only get the error when login in correctly with an existing email address.
After looking into the firebase documentation above more I printed: print(error?.userInfo[NSLocalizedFailureReasonErrorKey])
and
print(error?.userInfo[NSUnderlyingErrorKey])
to try and learn more and got these console logs
Optional(SecItemAdd (-34018))
nil
I'm very new to iOS development, but I have spent hours or googling and racking my brain trying to fix this and have made zero progress.
Again, everything was working just fine. All I did was updated to Swift 3.0 and this started happening. Any help would be really awesome, thank you!
ps. Sorry if I missed anything, this is my first time posting.
回答1:
Try turning on the Keychain Sharing in Capabilities of your projects' target. that worked for me. Keychain Sharing
回答2:
I found this issue in Firebase's release notes:
Authentication state is shared between different apps when running on the iOS Simulator: Description: when running two or more applications that use Firebase Authentication on the same iOS simulator, there is a issue with the iOS keychain that causes the authentication state to be shared across the different applications. This means that if you sign in to an app, and later open a second app, you may find a user to be signed in into it. Workaround: either don't use two different applications with Authentication on the same simulator instance, or manually sign out from the applications between tests.
Not sure if it's been fixed yet, but it seems to describe my situation when encountering the issue.
来源:https://stackoverflow.com/questions/38538160/an-error-occurred-while-accessing-the-keychain-when-signing-in-using-firebase