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 has 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.
Submit A Resource
Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?
You can submit the url here.
The resources we feel will appeal to our readers the most will be posted on the front page.