I want to store access token to keychain. But i got the error: Couldn't add the Keychain Item.'
I checked some posts on stackoverflow like: Storing email in keychain impossible (KeychainItemWrapper)
MyCode:
let a = NSKeyedArchiver.archivedData(withRootObject: "980a872c17a075367357e25e88c1c0476417092a")
let keyWrapper = KeychainItemWrapper.init(identifier: "23123123", accessGroup: nil)
keyWrapper?.setObject(a, forKey: kSecValueData)
I tried add this
keyWrapper?.setObject(kSecAttrAccessible, forKey: kSecAttrAccessible)
Change kSecValueData
to kSecAttrGeneric
I am running Xcode 8 with swift 3.0. Any hints thank you!
EDIT===========================
Viruss mca's answer turn on Share keychain entitlement just work once for me : (
I have recently face this issue with Xcode 8.
To solve the issue You have to add the "Share keychain entitlement" to Xcode capabilities.
There are many users who faced this issue.
Ref: https://forums.developer.apple.com/thread/60617
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With