{"id":17160410,"url":"https://github.com/rauhul/keychain","last_synced_at":"2025-10-23T11:13:33.186Z","repository":{"id":62456605,"uuid":"87752026","full_name":"rauhul/keychain","owner":"rauhul","description":"Keychain Access in Swift made easy","archived":false,"fork":false,"pushed_at":"2021-03-25T07:49:00.000Z","size":403,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-05T19:17:41.683Z","etag":null,"topics":["cocoapods","icloud","ios","keychain","swift","xcode"],"latest_commit_sha":null,"homepage":"https://rauhul.me/keychain","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rauhul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-10T01:13:10.000Z","updated_at":"2023-07-21T12:40:38.000Z","dependencies_parsed_at":"2022-11-02T00:15:16.309Z","dependency_job_id":null,"html_url":"https://github.com/rauhul/keychain","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauhul%2Fkeychain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauhul%2Fkeychain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauhul%2Fkeychain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rauhul%2Fkeychain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rauhul","download_url":"https://codeload.github.com/rauhul/keychain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240086592,"owners_count":19745839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","icloud","ios","keychain","swift","xcode"],"created_at":"2024-10-14T22:24:45.119Z","updated_at":"2025-10-23T11:13:27.844Z","avatar_url":"https://github.com/rauhul.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keychain\n[![Swift Version](https://img.shields.io/badge/swift-v5.0-orange.svg)](https://github.com/apple/swift)\n[![Documentation Converage](https://raw.githubusercontent.com/rauhul/keychain/master/docs/badge.svg?sanitize=true)](https://rauhul.me/keychain/)\n[![Release Version](https://img.shields.io/badge/release-v0.2.0-ff69b4.svg)](https://github.com/rauhul/keychain/releases)\n[![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/rauhul/keychain/master/LICENSE)\n\nA simple inteferace for using the iOS Keychain, written in Swift. Heavily based on the work done by Jason Rendel in [SwiftKeychainWrapper](https://github.com/jrendel/SwiftKeychainWrapper).\n\nProvides singleton instance `Keychain.default` that is setup to work for most needs.\n\nIf you need to customize the keychain access to use a custom identifier or access group, you can create your own instance instead of using the provided singleton.\n\nBy default, the Keychain saves data as a Generic Password type in the iOS Keychain. It saves items such that they can only be accessed when the app is unlocked and open. If you are not familiar with the iOS Keychain usage, this provides a safe default for using the keycain.\n\nUsers that want to deviate from this default implementation can specifiy keychain accessibility for each request (store, retrieve, etc...) to a Keychain instance.\n\n## Requirements\n- Swift 5.0+\n\n### Notes\nKeychain 0.1.2 is the last version that supports cocoapods\nKeychain 0.1.2 is the last release with Swift 4.2 support\n\n## Installation\n\n### Swift Package Manager\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.\n\nOnce you have your Swift package set up, adding Keychain as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n    .Package(url: \"https://github.com/rauhul/keychain.git\", from: \"0.2.0\")\n]\n```\n\nTo use the keychain in your app, import Keychain into the file(s) where you want to use it.\n\n``` swift\nimport Keychain\n```\n\n## General Usage\n\nStore a string value to keychain:\n\n``` swift\nlet saveSuccessful = Keychain.default.store(\"exampleValue\", forKey: \"exampleKey\")\n```\n\nRetrieve a string value from keychain:\n\n``` swift\nlet retrievedString = Keychain.default.retrieve(String.self, forKey: \"exampleKey\")\n```\n\nDelete a string value from keychain:\n\n``` swift\nlet removeSuccessful = Keychain.default.removeObject(forKey: \"exampleKey\")\n```\n\n## Custom Instance\n\nWhen the Keychain Wrapper is used, all keys are linked to a common identifier for your app, called the service name. By default this uses your main bundle identifier. However, you may also change it, or store multiple items to the keycahin under different identifiers.\n\nTo share keychain items between your applications, you may specify an access group and use that same access group in each application.\n\nTo set a custom service name identifier or access group, you may create your own keychain instance as follows:\n\n``` swift\nlet uniqueServiceName = \"customServiceName\"\n\nlet uniqueAccessGroup = \"sharedAccessGroupName\"\n\nlet customKeychainInstance = Keychain(serviceName: uniqueServiceName, accessGroup: uniqueAccessGroup)\n```\n\nThe custom instance can then be used in place of the provided instance:\n\n``` swift\nlet saveSuccessful = customKeychainInstance.store(\"exampleValue\", forKey: \"exampleKey\")\n\nlet retrievedString = customKeychainInstance.retrieve(String.self, forKey: \"exampleKey\")\n\nlet removeSuccessful = customKeychainInstance.removeObject(forKey: \"exampleKey\")\n```\n\n## Accessibility Options\n\nBy default, all items saved to keychain can only be accessed when the device is unlocked. To change this accessibility, an optional \"withAccessibility\" param can be set on all requests. The enum Keychain.Accessibilty provides an easy way to select the accessibility level desired:\n\n``` swift\nKeychain.default.store(\u003cKeychainStorable\u003e, forKey: \"exampleKey\", withAccessibility: .afterFirstUnlock)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frauhul%2Fkeychain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frauhul%2Fkeychain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frauhul%2Fkeychain/lists"}