kishikawakatsumi / KeychainAccess

Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.
MIT License
7.95k stars 789 forks source link

Synchronizable not working #492

Closed vitbulio closed 4 years ago

vitbulio commented 4 years ago

Hello. I'm using your keychain wrapper for saving and sharing passwords. All working fine. And now, I want to save these passwords in iCloud. There's no any errors when I saved password in try block, but when I trying to get my passwords Keychain.allItems(.internetPassword), I'm getting only not sync items. What's the problem? My code for saving password: let keychain = Keychain(server: serverUrlString, protocolType: protocolType, accessGroup: Consts.groupIdentifier, authenticationType: .default) .synchronizable(true)
.comment(comment) .label(label)

try keychain.set(inputPassword, key: username, ignoringAttributeSynchronizable: false)

vitbulio commented 4 years ago

Problem with getting sync items has been solved. First, I'm getting all keys let allKeys = Keychain.allKeys(.internetPassword) Then in forEach loop need's create keychain let keychain = Keychain(server: url, protocolType: ProtocolType.init(rawValue: protocolType) ?? .https, accessGroup: Consts.groupIdentifier), get password and get attributes (if needed). We can get url in forEach loop like this let url = URL(string: $0.0). After all, I'm logging the same iCloud on my Mac. After creating and sync passwords in your app, you can see immediately your saved data in Mac keychain. But I don't see that in saved passwords in my iPhone. Why?

vitbulio commented 4 years ago

Solved. Saved passwords shouldn't show in iPhone settings -> passwords and accounts. Just login the same iCloud account for different devices.