Contents

modern-swift-dev/lockbox-swift

Lockbox is a small, type-safe Swift wrapper around Apple Keychain Services and Local Authentication. It stores generic and internet passwords, supports raw Data, builds keychain queries from Swift enum values, and provides an iOS biometric credential service.

Requirements

  • Swift 6
  • macOS 15+, iOS 18+, tvOS 18+, watchOS 10+, or visionOS 1+

Some APIs have narrower platform availability. The documentation hub lists those limits.

Installation

Add https://github.com/modern-swift-dev/lockbox-swift.git as a Swift Package dependency in Xcode, then add the Lockbox product to your target.

For a package manifest, add the dependency and product:

dependencies: [
    .package(
        url: "https://github.com/modern-swift-dev/lockbox-swift.git",
        from: "1.0.0"
    )
],
targets: [
    .target(
        name: "YourTarget",
        dependencies: ["Lockbox"]
    )
]

Then import the library:

import Lockbox

Quick start

let password = KeychainPassword.generic(
    service: "com.example.account",
    account: "person@example.com"
)

try password.set(string: "a-secret")
let savedPassword = try password.getString()
try password.remove()

set(string:) and set(data:) create an item or update an existing match. Read methods return nil when an item does not exist.

See the getting started guide for the complete workflow and the examples for generic passwords, internet passwords, typed queries, and biometric credentials.

Contributing

Guides and examples live in Documentation/Site. The central documentation repository owns the shared Astro theme, builds the guides and DocC API reference, and publishes them daily. For local builds and previews, follow the docs README.

See CONTRIBUTING.md for contributor instructions.

License

Lockbox is available under the MIT License. See LICENSE.

Package Metadata

Repository: modern-swift-dev/lockbox-swift

Default branch: main

README: README.md