kishikawakatsumi / KeychainAccess

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

how to pass items from Keychain between iOS project and watchOS extension app #572

Open Maks273 opened 1 year ago

Maks273 commented 1 year ago

i tried to use accessGroup but I have no idea why it's not working, maybe I did something wrong...could you explain how to share data from Keychain between iOS and watchOS targets pls?

djmckee commented 1 year ago

+1, seeing this issue

kishikawakatsumi commented 1 year ago

Historically it was possible to share a keychain access group between your phone app and your watch extension because they both ran on the same device (the phone). This is no longer the case. Modern versions of watchOS run your watch extension on the watch, which is a different device from the phone app (the phone), and there’s no keychain access group sharing between devices. One option here is to push your keychain items up to iCloud Keychain via the

kSecAttrSynchronizable

option.

If the user does not use iCloud Sync, this functionality is not available. In that case, consider using Watch Connectivity to send and receive data directly, for example.

See also: https://damian.fyi/swift/2020/07/23/sharing-tokens-between-macos-ios-and-watchos-using-icloud-keychain.html https://www.wwdcnotes.com/notes/wwdc21/10003/

emkou commented 11 months ago

Not using the SPM but actually importing the files inside the main app target made it possible to user shared keychain between the apps, i guess tehre is something with shared keychain and SPM packages that makes this not possible