SwiftKeychainWrapper
SwiftKeychainWrapper copied to clipboard
XCTestCase: set NewValue return False
Hi, I try save string data on keychain, however, the function set return False.
Any idea ?
I post the code:
public static var tokenSession: String {
set {
KeychainWrapper.standard.set(
newValue,
forKey: "sm_token_session_key",
withAccessibility: .always,
isSynchronizable: true
)
}
get {
KeychainWrapper.standard.string(
forKey: "sm_token_session_key",
withAccessibility: .always,
isSynchronizable: true
) ?? .empty
}
}
@javierbc121086 it might work if you remove isSynchronizable. I'm guessing there's some info plist permission that needs to be added for sync to work. Maybe https://developer.apple.com/documentation/security/keychain_services/keychain_items/sharing_access_to_keychain_items_among_a_collection_of_apps?
Ah note, there must be something else going on here. The reason I wasn't getting anything back in my code was that I wasn't passing isSynchronizable to both the getter and the setter, just the setter. They both need it.