Introduction
Welcome to the documentation for UICKeyChainStore, a simple and secure library for storing data in the keychain on iOS.
UICKeyChainStore provides a convenient and easy-to-use API for interacting with the keychain, allowing you to securely store and retrieve sensitive information such as passwords, access tokens, and other credentials.
Requirements
- iOS 9.0+
Installation
To install UICKeyChainStore, you can either use CocoaPods or manually add the framework to your project.
Using CocoaPods
To use UICKeyChainStore with CocoaPods, add the following line to your Podfile:
pod 'UICKeyChainStore'
Manual Installation
If you prefer to manually add the framework to your project, follow these steps:
- Download the latest version of UICKeyChainStore from the GitHub repository.
- Extract the downloaded file and locate the UICKeyChainStore.framework.
- Drag and drop the framework into your Xcode project.
- In the “General” settings for your target, add UICKeyChainStore.framework to the “Embedded Binaries” section.
Usage
Using UICKeyChainStore is straightforward. Simply follow the steps below:
1. Import the framework
In your Swift file, import UICKeyChainStore:
import UICKeyChainStore
2. Create an instance of UICKeyChainStore
To use UICKeyChainStore, create an instance of it:
let keychain = UICKeyChainStore(service: "")
3. Store data in the keychain
To store data in the keychain, use the following method:
keychain[""] = ""
4. Retrieve data from the keychain
To retrieve data from the keychain, use the following method:
let value = keychain[""]
5. Delete data from the keychain
To delete data from the keychain, use the following method:
keychain.remove()
Additional Features
Access Control
UICKeyChainStore also supports setting access control for the stored data. You can specify the access control level as needed:
let accessControl = SecAccessControlCreateWithFlags(nil, .userPresence, [.privateKeyUsage, .applicationPassword, .devicePasscode])
keychain.accessibility(.whenUnlockedThisDeviceOnly, accessControl: accessControl)
Data Accessibility
You can set the data accessibility level according to your requirements using the `accessibility` method:
keychain.accessibility(.afterFirstUnlock)
Synchronization
To enable data synchronization across multiple devices, you can set the `synchronizable` property:
keychain.synchronizable = true
Conclusion
With UICKeyChainStore, you can easily store and retrieve sensitive data securely in the keychain on iOS. Take advantage of the features provided by this library to enhance the security and convenience of your app.