This is yet another Keychain Services wrapper - queue the eye roll. I tried out quite a number, they felt overly abstracted, underimplemented or confusing. Even Apple has one. I liked Sam Soffes' SAMKeychain, but it only supports kSecClassGenericPassword. In particular, I was looking for kSecClassInternetPassword. SecureStore supports both very well and can expand to other types (certificates, keys, identities, etc).
The goal was to pickup a good project and adapt it as necessary, I don't like to re-invent wheels, and found one written by Lorenzo Boaro, it's part of RayWenderlich.com tutorial Keychain Services API Tutorial for Passwords in Swift. Unfortunately, neither the author nor the project where on GitHub. Also, the project - while written multiplatform - only targeted iOS. I highly recommend Lorenzo's post, it describes the Keychain operation very well.
So this code / Framework starts where its predecessor left off, by taking the pristine sources and enhancing / adapting for real life Framework usage. Please note that the original copyright and permission has been kept, as requested by the author. If you are interested in the process and adapting of the code, take a look at the commit log.
Adding To Your Project
Swift Package Manager is in the works. Right now Carthage is the way to go:
Check the tests for call examples, most are very atomic.
Currently, the project is ready to use and defaults to macOS builds.
- iOS Target
- macOS and passes all but 2 tests. The original source passes all tests under iOS.
Changes from Original Source
- Independent project and framework with shared schema for Carthage
- Public Queryable structs initializers
Feel free to fork a copy and create a pull request.
Both API documentation and examples plus a patient description of Keychain Services can be found at Keychain Services API Tutorial for Passwords in Swift.