Previously I mentioned a nice Objective-C library for easily saving NSUSerDefaults data to the keychain called PDKeychainBindingsController.
Here’s a very complete Swift wrapper library of the iOS C Keychain API submitted by Denis Krivitski called KeychainSwiftAPI.
Dealing with the the C based Keychain API can be extremely tedious, and KeychainSwiftAPI gas neatly wrapped all the functions, and attributes of the C API following the best security coding practices and guidelines in order to avoid any security vulnerabilities.
This code example from the readme shows how to create a query object, populate it with values, and call a keychain object:
q.kSecClass = Keychain.Query.KSecClassValue.kSecClassGenericPassword
q.kSecAttrDescription = "A password from my website"
q.kSecAttrGeneric = "VerySecurePassword".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
q.kSecAttrAccount = "admin"
q.kSecReturnData = true
q.kSecReturnAttributes = true
q.kSecReturnRef = true
q.kSecReturnPersistentRef = true
let r = Keychain.secItemAdd(query: q)
The API is very close to the C API so there should be little difficulty when following any documentation using the C API.
You can find KeychainSwiftAPI on Github here.
A nice Swift keychain wrapper.
Original article: Open Source Library Providing A Complete Swift Based Wrapper Of The C Based iOS Keychain API
©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.