Latest 1.2
Homepage https://github.com/radude89/KeychainStorage
License MIT
Platforms ios 12.0, requires ARC
Authors

Keychain Storage

build
Carthage


Carthage

iOS
Twitter: @radude89

Keychain Storage is a simple Keychain wrapper written in Swift.
If you ever wanted to save something in Keychain without writing too much code, you are in the right place.

Requirements

  • iOS 12.0+
  • Xcode 10.2+
  • Swift 5+

Installation

Cocoa Pods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Keychain Storage into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'KeychainStorage', '~> 1.2'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate KeychainStorage into your Xcode project using Carthage, specify it in your Cartfile:

github "radude89/KeychainStorage" "1.2"

Manual

Just drag and drop into your project the following projects found in KeychainStorage:

  • KeychainQueryFactory.swift
  • KeychainStorage.swift
  • KeyValueStorage.swift

Examples

Make sure you try out the small app, the example project found at: Example/KeychainStorageExample.xcworkspace.
Build & run.

Saving a value in Keychain

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.set("secret", key: "myStringKey")

try? storage.set(true, key: "myBoolKey")

Retrieving a value from Keychain

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")

if let myStringValue = try? storage.string(forKey: "myStringKey") {
    // do something with myStringValue
}

if let myBoolValue = try? storage.bool(forKey: "myBoolKey") {
    // do something with myBoolValue
}

Deleting a value from Keychain

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.removeValue(forKey: "myStringKey")

Deleting all values from Keychain

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.removeAll()

License

KeychainStorage is released under the MIT license. See LICENSE for details.

Contributions & support

KeychainStorage is developed as an open source project. I encourage everyone to contribute.

Please do make pull requests if you have suggestions or ideas of improvement.

Thanks!

Latest podspec

{
    "name": "KeychainStorage",
    "platforms": {
        "ios": "12.0"
    },
    "summary": "KeychainStorage is a simple wrapper for Keychain items. Use it to quickly save and retrieve sensitive information from Keychain.",
    "requires_arc": true,
    "version": "1.2",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Radu Dan": "[email protected]"
    },
    "homepage": "https://github.com/radude89/KeychainStorage",
    "source": {
        "git": "https://github.com/radude89/KeychainStorage.git",
        "tag": "1.2"
    },
    "source_files": "KeychainStorage/*.{swift}",
    "swift_versions": "5.0",
    "ios": {
        "frameworks": "Security"
    },
    "swift_version": "5.0"
}

Pin It on Pinterest

Share This