BeatChain
BeatChain copied to clipboard
BeatChain is a manager for saving and retrieving string values into keychain written in swift.
BeatChain
BeatChain is a manager for saving and retrieving string values into keychain written in swift.
Contents
- Requirements
- Installation
- Usage
- Documentation
- License
- Authors
- Credits
Requirements
- iOS 10.0+
- Swift 4.0+
- Xcode 10.0+
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
to integrate BeatChain into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'BeatChain', '~> 1.0.0'
end
then, run the following command, this will fetch and install the BeatChain pod:
$ pod install
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew install carthage
to integrate BeatChain into your Xcode project using Carthage, specify it in your Cartfile:
github "beatlabs/BeatChain" "master"
Run carthage update to build the framework and drag the built BeatChain.framework into your Xcode project.
Swift Package Manager
You can use The Swift Package Manager to install BeatChain by adding the proper description to your Package.swift file:
// swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
dependencies: [
.package(url: "https://github.com/beatlabs/BeatChain.git", from: "1.0.0"),
]
)
then, run the following command:
$ swift build
Manually
If you prefer you can build the framework manually and drag generated framework BeatChain.framework into your Xcode project.
Usage
Quick Start
import BeatChain
let keychainManager = KeychainManager()
// save password into keychain
do {
let item = GenericPasswordItem(account: "username", accessGroup: "accessGroup")
try keychainManager.saveValue(password, to: item)
} catch {
assertionFailure("Save password failed")
}
// read password from keychain
do {
let item = GenericPasswordItem(account: "account", accessGroup: "accessGroup")
return try keychainManager.readValue(item)
} catch KeychainManagerError.noItemFound {
assertionFailure("Item not found")
} catch {
assertionFailure("Get password failed")
}
// delete password item from keychain
do {
let item = GenericPasswordItem(account: nil, accessGroup: "accessGroup")
try keychainManager.deleteItem(item)
} catch {
assertionFailure("Delete password failed")
}
Documentation
Install Jazzy
$ gem install jazzy
then you can generate documentation by using the following command:
$ jazzy --min-acl internal
License
BeatChain is released under the Apache License Version 2.0. See LICENSE for details.
Authors
The iOS BEAT team
https://github.com/beatlabs/BeatChain