Reputation: 6526
I'm having issues with keychain on iOS 10 devices. Failed to retrieve saved users, only happens with iOS 10 users, authentication is with Firebase. This is the error:
Error loading saved user when starting up: Error Domain=FIRAuthErrorDomain Code=17995 "An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered" UserInfo={NSLocalizedDescription=An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered, error_name=ERROR_KEYCHAIN_ERROR, NSLocalizedFailureReason=SecItemCopyMatching (0)}
Upvotes: 19
Views: 7254
Reputation: 502
This started to happen in my project since I updated the SDK to Firebase 11.0.0 when doing
Auth.auth().updateCurrentUser(unsharedUser, completion: { error in
...
I just downgraded again to 10.29.0 in the meantime of figuring out if it is a bug or we have to do things in a different way to have it working properly.
Didn't find anything related to this in the release notes.
Upvotes: 1
Reputation: 11
This worked for me, but I'm not sure if it will work for everyone. Go to your target and click on the "signings & capabilities" tab. Click "+Capability" in the upper left and add "App Group". Add your group.member.project or whatever your keychain is there and delete the keychain capability. If you get an error regarding your entitlements file clear your build folder (Product > Clear Build Folder) and see if you can build it again!
Upvotes: 0
Reputation: 3379
Building on @bash0ne's answer:
First, do what @bash0ne said, namely (modified for the newer version of Xcode):
Then, add a Keychain group. To do so, in Signing & Capabilities (same section as before) scroll to the "Keychain Sharing" section. There is a table for "Keychain Groups," and you can add to this table.
As this answer says, the keychain group needs to have this format:
<TEAM_ID>.<APP_NAME>.<GROUP_NAME>
If you click "+", Xcode adds the default group, and the default that Xcode added worked for me.
Final, somewhat separate note. Users in the comments asked how to check "userInfo" for the error. You have to cast the error as NSError and then check, as such (assumes error
is of type Error?
):
print((error! as NSError).userInfo)
Upvotes: 3
Reputation: 477
My issue (same as above) was fixed by simply removing the$(AppIdentifierPrefix) string which is added to the entitlements file (if you use Xcode UI to add the keychain sharing group).
Upvotes: 0
Reputation: 424
As mentioned in the link of the first answer there is a workaround:
Btw, is there an issue tracker for xcode?
Upvotes: 22