The easiest way to securely store data in the keychain. It's implementation is really close to the UserDefaults.

What's New

Keychain.swift v1.0.5


Adding support for macOS


A swift package to easily implement Keychain on your iOS apps, with a UserDefaults-like implementation.


Add to your Swift Package configuration (or using the Xcode menu: File > Swift Packages > Add Package Dependency)


// Import the package
import Keychain

// When your need to access the Keychain, initialize it like this:
let keychain = Keychain()

// If you want to use an access group for your Keychain, pass it as a String argument
// let keychain = Keychain(accessGroup: "")

// To save a value for a key named "yourKey", simply use:
let saved:Bool =, forKey: "yourKey")
// The returned boolean indicates if the operation was successful

// To read a value for this key
let value = keychain.value(forKey: "yourKey") as? Int ?? 0

// And finally to delete your key and it's value, use:
let deleted:Bool = keychain.remove(forKey: "yourKey")
// The returned boolean indicates if the operation was successful


  • Swift Tools 5.2.0
View More Packages from this Author


  • None
Last updated: Tue Mar 14 2023 06:05:29 GMT-0500 (GMT-05:00)