SimpleKeychain Documentation
Welcome to the documentation page for SimpleKeychain, a library that provides easy access to keychain services in iOS and Mac apps. This library simplifies keychain management, making it effortless to store and retrieve secure data such as passwords, tokens, and other sensitive information.
Installation
- Download the SimpleKeychain library from the official GitHub repository – https://github.com/auth0/simple-keychain.
- Unzip the downloaded file.
- Open your Xcode project.
- Drag and drop the
SimpleKeychain.swift
file into your Xcode project’s directory. - Make sure to check the box next to “Copy items if needed”.
- Click on your Xcode project’s name in the project navigator, go to the “Build Phases” tab, and ensure that the
SimpleKeychain.swift
file is included under “Compile Sources”. - You are now ready to use SimpleKeychain in your project!
Usage
Using SimpleKeychain is straightforward. Here are some common operations:
Adding an Item
- Import the SimpleKeychain framework into your code.
- Create an instance of the SimpleKeychain class.
- Call the
set
method on the instance and pass the key and value as parameters. - Optionally, you can specify an access group for shared keychain access when using multiple apps.
Retrieving an Item
- Import the SimpleKeychain framework into your code.
- Create an instance of the SimpleKeychain class.
- Call the
get
method on the instance and pass the key as a parameter. - The method will return the value corresponding to the key if found in the keychain.
Deleting an Item
- Import the SimpleKeychain framework into your code.
- Create an instance of the SimpleKeychain class.
- Call the
delete
method on the instance and pass the key as a parameter. - The method will remove the item associated with the key from the keychain.
Example Usage
import SimpleKeychain
let keychain = SimpleKeychain()
// Adding an item
keychain.set("myPassword", forKey: "password")
// Retrieving an item
if let password = keychain.get("password") {
print("Password: \(password)")
}
// Deleting an item
keychain.delete("password")
Congratulations! You now have a solid understanding of how to integrate SimpleKeychain into your iOS or Mac app. For more advanced usage or additional methods, please refer to the official SimpleKeychain GitHub repository.