A Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness and flexibility.

Last update: Jun 28, 2022

KCM Logo

Keychain Manager

Keychain Manager is a Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness and flexibility. It focuses on using all the power of Keychain with high simplicity. The easy to use methods of Keychain Manager helps to setup Keychain on any Apple device with great convenience.

๐Ÿ“” Usage

โš™๏ธ Intilisation

Before using any Keychain Manager methods we need to intialise the class. Keychain Manager supports various types of inilisation which depends upon variety of use cases

๐Ÿ—ณ Basic Initialisation

  • This initilisation stores all the Keychain items on the local device.
  • Such initilisations are best used when the app is single login based.
let KCM = KeychainManager()

๐Ÿ—ณ Prefix Initiliser

  • This initiliser helps to add a prefix value in your account string.
  • Such initilisations are best used when performing tests (Eg: test_account1_).
 let KCM = KeychainManager(keyPrefix: "test")

๐Ÿ—ณ Sharable Initiliser

  • Keychain Manger allowes developers to share the keychain values to other apps also synchronise with iCloud.
  • Such initilisations are best used when you need to share Keychain values among apps.
  • Eg: A same app running on two different devices with same iCloudID & To share data between Different apps running on same or different device
let KCM = KeychainManager(accessGroup: "TeamID.KeychainGroupID", synchronizable: true)

๐Ÿ—ณ Prefix + Sharable

  • When you need to add both prefix and sharable propert on keychain then this initialisation is the best one to use
 let KCM = KeychainManager(keyPrefix: "test", accessGroup: "TeamID.KeychainGroupID", synchronizable: true)

๐Ÿ›  Operations

Following are the methods which help to perfrom various operations:

๐Ÿ”‘ SET

  • Used to save data on keychain.
  • Keychain Manager Supports variety of data storage

String

KCM.set(value: "value", service: service_ID, account: account_name)

Bool

KCM.set(value: true, service: service_ID, account: account_name)

Custom Object

KCM.set(object: Any_Codable_Object, service: service_ID, account: account_name)

Web Credentials

KCM.set(server: server_ID, account: account_name, password: password)

Tip: Make sure Account, Service & Server parameter must be unique for every item.

๐Ÿ”‘ GET

  • Used to get Keychain Items.
  • Keychain Manager helps to GET variety of format of Data from Keychain Storage

String

let value = KCM.get(service: service_ID, account: account_name)

Bool

let value = KCM.getBool(service: service_ID, account: account_name)

Custom Object

 let value = KCM.get(object: Any_Codable_Object, service: service_ID, account: account_name)

Web Credentials

let value = KCM.get(server: server_ID, account: account_name)

Get All Values

  • Generic Password
 let value = KCM.getAllValues(secClass: .genericPassword)
  • Web Credentials
 let value = KCM.getAllValues(secClass: .webCredentials)

๐Ÿ”‘ UPDATE

  • Used to update Kechain Item Values
  • Since we have variety of SET and GET methods, similarly to update them we have variety of UPDATE methods

String

KCM.update(value: "value", service: service_ID, account: account_name)

Bool

KCM.update(value: true, service: service_ID, account: account_name)

Custom Object

KCM.update(object: Any_Codable_Object, service: service_ID, account: account_name)

Web Credentials

KCM.update(server: server_ID, account: account_name, password: password)

๐Ÿ”‘ DELETE

  • Used to delete Keychain Items

Service Deletion

 do {
    try KCMTest.delete(service: service_ID, isCustomObjectType: false)
 }
 catch {
    print(error.localizedDescription)
}
  • isCustomObjectType is used to explicitly tell Keychain Manager to delete a custom Object type.
  • By default the value of isCustomObjectType is false

Server Deletion

 do {
    try KCMTest.delete(server: server_ID)
 }
 catch {
    print(error.localizedDescription)
}

๐Ÿ”‘ VALIDATE

  • Is used to check if a certain Server or Service based keychain is valid/present.

Service

 if KCM.isValidService(service: service_ID, account: account_name) {
        print("๐Ÿ™‚")
 } else {
        print("โ˜น๏ธ")
 }

Server

 if KCM.isValidService(server: server_ID, account: account_name) {
     print("๐Ÿ™‚")
 } else {
     print("โ˜น๏ธ")
 }

โ˜๏ธ iCloud Sync

  • iCloud synchronisation needs to be set during initilisation.
  • Make sure to use the sharable initialisation at every method to save all changes on cloud.

๐Ÿ“ฑ Device Supported

No Device Version
1 iOS 13.0.0 +
2 iPadOS 13.0.0 +
3 WatchOS 6.0.0 +
4 MacOS 11.0.0 +
5 tvOS 11.0.0 +

๐Ÿ“Œ Keynotes

Make sure you know these keynotes before using Keychain Manager

  • GET Bool will return false even after deleting the Keychain item.
  • To delete a custom object make sure you explicitly tell Keychain Manager that its a custom object in the delete method.
  • By enabling iCloud sync you also enable Keychain Access Group, thus adding Keychain Sharing capability is important (How to do it?).
  • Every Keychain item stored through MacOS is also saved in form of iOS, making it easy for developers to share same keychain data among all platforms. Thus keychain manager will give access to your MacOS based keychain items on other platforms too (Read this).
  • Keychain Items stored on tvOS will not sync with other platforms (Read this).

๐Ÿ“ฆ SPM

Keychain Manger is available through Swift Package Manager. To add Keychain Manager through SPM

  • Open project in Xcode
  • Select File > Add Packages
https://github.com/gokulnair2001/KeychainManager

SPM Dialogue

๐ŸŒ Keychain Sharing

  • Open your project target
  • Select Signing & Capabilities option
  • Click plus button and search for Keychain Sharing

Keychain Sharing Capability

Screenshot 2022-06-17 at 3 38 39 PM

  • Make sure to use the same Keychain Item in other apps you add the Keychain access group ID of the initial project.

๐Ÿช„ How to contribute ?

  • Use the framework through SPM
  • If you face issues in any step open a new issue.
  • To fix issues: Fork this repository, make your changes and make a Pull Request.

โš–๏ธ License

  • Keychain Manager is available under GNU General Public License.

Like the framework ?

  • If you liked Keychain Manager do consider buying me a coffee ๐Ÿ˜Š

BMC logo+wordmark - Black

Made with โค๏ธ in ๐Ÿ‡ฎ๐Ÿ‡ณ By Gokul Nair

GitHub

https://github.com/gokulnair2001/KeychainManager
You might also like...

Recover lost keychain passwords with swift

brutalkeychain Recover lost keychain passwords using a simple swift script (so c

Dec 24, 2021

Keep track of accessibility settings, leverage high contrast colors, and use scalable fonts to enable users with disabilities to use your app.

Keep track of accessibility settings, leverage high contrast colors, and use scalable fonts to enable users with disabilities to use your app.

Accessibility for iOS, macOS, tvOS, and watchOS ๐ŸŽ‰ What's new in Capable 2.0 ๐ŸŽ‰ Here are the most important changes: ๐Ÿ› New framework architecture and

Jul 30, 2022

Swift managers package for the easiness of working with the various services.

SwiftManagers Description Swift managers package for the easiness of working with the various services. FirebaseAuth - Manager to handle Firebase auth

Apr 29, 2022

A view that shows selectable symbols, similar to UITableView's `sectionIndexTitles` API but with support for symbols and more flexibility

A view that shows selectable symbols, similar to UITableView's `sectionIndexTitles` API but with support for symbols and more flexibility

๐Ÿ“– TableOfContentsSelector Are you familiar with UITableView's sectionIndexTitles API? The little alphabet on the side of some tables for quickly jump

Jun 14, 2022

iCloud Drive is Apple's essential connection between all your devices, Mac, iPhone, iPad, even your Windows PC.

iCloud Drive is Apple's essential connection between all your devices, Mac, iPhone, iPad, even your Windows PC.

iCloud Drive is Apple's essential connection between all your devices, Mac, iPhone, iPad, even your Windows PC.While the cost of storage seems expensive in comparison to other online storage services, its advantage is that it works natively across all your devices.

Jul 29, 2022

Appstoreconnect-register-devices - A web app that lets users register their devices to your provisioning profile. Built with vapor

App Store Connect API - Vapor Web App Example This is an example web app built u

May 22, 2022

Meet cute and very flexibility library for iOS application for different data view in one circle diagram.

Meet cute and very flexibility library for iOS application for different data view in one circle diagram.

SMDiagramViewSwift Meet cute and very flexibility library for iOS application for different data view in one circle diagram. The opportunity of transf

Aug 1, 2022

A simple and flexible way to add source of overlapping circular pictures, currently supports horizontal overlapping or distant pictures with great layout flexibility.

A simple and flexible way to add source of overlapping circular pictures, currently supports horizontal overlapping or distant pictures with great layout flexibility.

THIS PROJECT IS NO LONGER MAINTAINED. STILL ONE ONLY BEST UI SOLUTION FOR UIKIT DEVELOPERS. SOON WILL COME UP WITH SWIFTUI STILL CONTRIBUTORS ARE WELC

Jul 13, 2022

Swift Paging is a framework that helps you load and display pages of data from a larger dataset from local storage or over network.

Swift Paging is a framework that helps you load and display pages of data from a larger dataset from local storage or over network. This approach allows your app to use both network bandwidth and system resources more efficiently. It's built on top of Combine, allowing you to harness its full power, handle errors easily, etc.

Feb 7, 2022

UICKeyChainStore is a simple wrapper for Keychain on iOS, watchOS, tvOS and macOS. Makes using Keychain APIs as easy as NSUserDefaults.

UICKeyChainStore UICKeyChainStore is a simple wrapper for Keychain that works on iOS and OS X. Makes using Keychain APIs as easy as NSUserDefaults. Lo

Aug 1, 2022

Zephyr synchronizes specific keys and/or all of your UserDefaults over iCloud using NSUbiquitousKeyValueStore.

Zephyr synchronizes specific keys and/or all of your UserDefaults over iCloud using NSUbiquitousKeyValueStore.

Zephyr ๐ŸŒฌ๏ธ Effortlessly sync UserDefaults over iCloud About Zephyr synchronizes specific keys and/or all of your UserDefaults over iCloud using NSUbiq

Aug 5, 2022

๐Ÿ›ถShallows is a generic abstraction layer over lightweight data storage and persistence.

Shallows Shallows is a generic abstraction layer over lightweight data storage and persistence. It provides a StorageKey, Value type, instances of w

Aug 3, 2022

SecureDefaults is a wrapper over UserDefaults/NSUserDefaults with an extra AES-256 encryption layer

SecureDefaults for iOS, macOS Requirements โ€ข Usage โ€ข Installation โ€ข Contributing โ€ข Acknowledgments โ€ข Contributing โ€ข Author โ€ข License SecureDefaults is

Jul 22, 2022

Reactive WebSockets - A lightweight abstraction layer over Starscream to make it reactive.

RxWebSocket Reactive extensions for websockets. A lightweight abstraction layer over Starscream to make it reactive. Installation RxWebSocket is avail

Jul 22, 2022

SQLite.swift - A type-safe, Swift-language layer over SQLite3.

 SQLite.swift - A type-safe, Swift-language layer over SQLite3.

SQLite.swift provides compile-time confidence in SQL statement syntax and intent.

Aug 3, 2022

A lightweight wrapper over UserDefaults/NSUserDefaults with an additional layer of AES-256 encryption

SecureDefaults for iOS, macOS Requirements โ€ข Usage โ€ข Installation โ€ข Contributing โ€ข Acknowledgments โ€ข Contributing โ€ข Author โ€ข License SecureDefaults is

Jul 22, 2022

MapTeam - A type-safe, Swift-language layer over SQLite3

MapTeam - A type-safe, Swift-language layer over SQLite3

SQLite.swift A type-safe, Swift-language layer over SQLite3. SQLite.swift provid

Jan 18, 2022

A snake engine written in SpriteKit for all Apple devices.

A snake engine written in SpriteKit for all Apple devices.

A snake engine written in SpriteKit for all Apple devices. โญ Features Fully tested engine functionality. Framework based, super easy to integrate in d

Jul 25, 2022

Valet lets you securely store data in the iOS, tvOS, or macOS Keychain without knowing a thing about how the Keychain works.

Valet Valet lets you securely store data in the iOS, tvOS, watchOS, or macOS Keychain without knowing a thing about how the Keychain works. Itโ€™s easy.

Aug 3, 2022
Valet lets you securely store data in the iOS, tvOS, or macOS Keychain without knowing a thing about how the Keychain works. Itโ€™s easy. We promise.

Valet Valet lets you securely store data in the iOS, tvOS, watchOS, or macOS Keychain without knowing a thing about how the Keychain works. Itโ€™s easy.

Aug 3, 2022
Keychain - Keychain wrapper with swift

Keychain wrapper. Store a value as a generic password: let account = "an-arbitra

Mar 14, 2022
Modern Swift wrapper for Keychain Services API with the benefits of static typing

SwiftyKeychainKit SwiftyKeychainKit is a simple Swift wrapper for Keychain Services API with the benefits of static typing. Define your keys in one pl

Mar 29, 2022
A keychain wrapper that is so easy to use that your cat could use it.

A keychain wrapper that is so easy to use that your cat could use it.

Jul 13, 2022
Example of using TOTP with iCloud Keychain in iOS 15

Installation This example needs Ngrok and Ruby 3.0.3+. Setup project with Makefi

Dec 31, 2021
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.

KeychainAccess KeychainAccess is a simple Swift wrapper for Keychain that works on iOS and OS X. Makes using Keychain APIs extremely easy and much mor

Aug 6, 2022
Simple Objective-C wrapper for the keychain that works on Mac and iOS

SAMKeychain SAMKeychain is a simple wrapper for accessing accounts, getting passwords, setting passwords, and deleting passwords using the system Keyc

Aug 2, 2022
A powerful, protocol-oriented library for working with the keychain in Swift.

Locksmith A powerful, protocol-oriented library for working with the keychain in Swift. ?? iOS 8.0+ ?? Mac OS X 10.10+ โŒš๏ธ watchOS 2 ?? tvOS ?? I make

Aug 2, 2022
A simple wrapper for the iOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift.

SwiftKeychainWrapper A simple wrapper for the iOS / tvOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift. Prov

Aug 8, 2022
Recover lost keychain passwords with swift

brutalkeychain Recover lost keychain passwords using a simple swift script (so c

Aug 2, 2022