0xWDG/SecureStorage
SecureStorage is a property wrapper around the keychain to easily access your protected data.
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)
- In Xcode, open your project and navigate to File β Swift Packages β Add Package Dependency...
- Paste the repository URL (
https://github.com/0xWDG/SecureStorage) and click Next. - 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.
Package Metadata
Repository: 0xWDG/SecureStorage
Homepage: https://0xwdg.github.io/SecureStorage/
Stars: 4
Forks: 0
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
Topics: 0xwdg, hacktoberfest, keychain, propertywrapper, securestorage, swift, swiftui
README: README.md