SimpleKeychain v1 includes a few significant changes:
- Improved error handling.
- Support for custom attributes.
- Support for sharing items with other devices through iCloud synchronization.
As expected with a major release, SimpleKeychain v1 contains breaking changes. Please review this guide thorougly to understand the changes required to migrate your application to v1.
- Supported Languages
- Supported Platform Versions
- Types Removed
- Properties Removed
- Methods Removed
- Types Changed
- Method Signatures Changed
- Behavior Changes
The minimum supported Swift version is now 5.5.
SimpleKeychain no longer supports Objective-C.
The deployment targets for each platform were raised to:
- iOS 12.0
- macOS 10.15
- tvOS 12.0
- watchOS 6.2
- The
A0SimpleKeychainErrorenum was removed in favor of the newSimpleKeychainErrorenum. - The
A0SimpleKeychainItemAccessibleenum was removed in favor of the newAccessibilityenum. - The
A0ErrorDomainmacro was removed. - The
A0LocalAuthenticationCapablemacro was removed.
The property defaultAccessiblity was removed in favor of the new accessibility initalizer parameter.
Before / After
// Before
let simpleKeychain = A0SimpleKeychain()
simpleKeychain.defaultAccessiblity = .whenPasscodeSetThisDeviceOnly
// After
let simpleKeychain = SimpleKeychain(accessibility: .whenPasscodeSetThisDeviceOnly)The property useAccessControl was removed in favor of the new accessControlFlags initializer parameter.
Before / After
// Before
let simpleKeychain = A0SimpleKeychain()
simpleKeychain.useAccessControl = true
// After
let simpleKeychain = SimpleKeychain(accessControlFlags: .userPresence)The property localAuthenticationContext was removed in favor of the new context initializer parameter. This means that SimpleKeychain will no longer create an LAContext instance, and instead one must be provided through the initializer.
Before / After
// Before
let simpleKeychain = A0SimpleKeychain()
let context = simpleKeychain.localAuthenticationContext
// After
let context = LAContext()
let simpleKeychain = SimpleKeychain(context: context)The following properties are no longer public:
serviceaccessGroup
The setTouchIDAuthenticationAllowableReuseDuration(_:) method was removed. Configure that through an LAContext instance instead.
Before / After
// Before
let simpleKeychain = A0SimpleKeychain()
simpleKeychain.setTouchIDAuthenticationAllowableReuseDuration(10)
// After
let context = LAContext()
context.touchIDAuthenticationAllowableReuseDuration = 10
let simpleKeychain = SimpleKeychain(context: context)The following methods were removed and have no replacement:
publicRSAKeyData(forTag:)generateRSAKeyPair(withLength:publicKeyTag:privateKeyTag:)dataForRSAKey(withTag:)keyRefOfRSAKey(withTag:)deleteRSAKey(withTag:)hasRSAKey(withTag:)
A0SimpleKeychain was renamed to SimpleKeychain, and was changed from class to struct.
All the methods now throw a SimpleKeychainError upon failure.
| Old | New |
|---|---|
setString(forKey:) |
set(_:forKey:) |
setData(forKey:) |
set(_:forKey:) |
hasValue(forKey:) |
hasItem(forKey:) |
deleteEntry(forKey:) |
deleteItem(forKey:) |
clearAll() |
deleteAll() |
The promptMessage parameter was removed from the following methods, as kSecUseOperationPrompt is deprecated:
string(forKey:)data(forKey:)set(_:forKey:)
Configure the message through an LAContext instance instead, using the LAContext.localizedReason property.
The error parameter was removed from the data(forKey:) method, as it now throws a SimpleKeychainError.
kSecUseAuthenticationUIis no longer used. Configure whether the user should be prompted for authentication through anLAContextinstance instead, using theLAContext.interactionNotAllowedproperty.- The
hasItem(forKey:)method no longer retunsfalsewhenever any error occurs. Now it only returnsfalsewhen the error iserrSecItemNotFound.