SecureStorage

0.0.4

SecureStorage is a property wrapper around the keychain to easily access your protected data.
0xWDG/SecureStorage

What's New

0.0.4

2025-03-13T18:52:22Z

Property wrapper now works in a ObservableObject ๐ŸŽ‰

Full Changelog: 0.0.3...0.0.4

SecureStorage

SecureStorage is a property wrapper around the keychain to easily access your protected data.

Swift Package Manager License

Requirements

  • Swift 5.9+ (Xcode 15+)
  • iOS 13+, macOS 10.15+

Installation (Pakage.swift)

dependencies: [
    .package(url: "https://github.com/0xWDG/SecureStorage.git", branch: "main"),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "SecureStorage", package: "SecureStorage"),
    ]),
]

Installation (Xcode)

  1. In Xcode, open your project and navigate to File โ†’ Swift Packages โ†’ Add Package Dependency...
  2. Paste the repository URL (https://github.com/0xWDG/SecureStorage) and click Next.
  3. Click Finish.

Usage

import SwiftUI
import SecureStorage

struct ContentView: View {
    // For this example, we directly bind the username & password.
    // This is not smart to do, because you'll overwrite the values as you type.
    @SecureStorage("username")
    var username: String?

    @SecureStorage("password")
    var password: String?

    var body: some View {
        VStack {
            Text("Please login")
            TextField("Username", text: $username ?? "")
            SecureField("Password", text: $password ?? "")

            Button("Login") {
                print("Login", username, password)
            }
            Button("Delete username") {
                SecureStorage("username").delete()
            }
            Button("Delete password") {
                SecureStorage("password").delete()
            }
            Button("Delete username") {
                SecureStorage("*").deleteAll()
            }
        }
    }
}

Contact

๐Ÿฆ‹ @0xWDG ๐Ÿ˜ mastodon.social/@0xWDG ๐Ÿฆ @0xWDG ๐Ÿงต @0xWDG ๐ŸŒ wesleydegroot.nl ๐Ÿค– Discord

Interested learning more about Swift? Check out my blog.

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun May 04 2025 01:28:17 GMT-0900 (Hawaii-Aleutian Daylight Time)