SkillAgentSearch skills...

PasscodeKit

🔐 Easily add a passcode to your iOS app

Install / Use

/learn @divadretlaw/PasscodeKit
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

PasscodeKit

Easily add a passcode to your iOS app

Usage

PasscodeKit is split into two modules and depending on what you need you can use the main or core module.

PasscodeKit

<img width="200" alt="Screenshot" src="https://github.com/divadretlaw/PasscodeKit/assets/6899256/f9328b38-7b17-42b0-ab4b-3e07dad4f1d6">

The default module, with UI and handling already setup. Simply add .passcode(title:hint:), with an optional title and hint view, to your root view.

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .passcode("Enter Passcode") {
                    // Optional view as a hint above the code view
                }
        }
    }
}

The passcode has to be setup by the user in order to be used, you can add this modifier to any view to start the setup.

.setupPasscode(isPresented: $setupPasscode, type: .numeric(6))

To remove the passcode again, use the environment variables to access the . You can also set the manager environment variable to override the used Keychain instance and key where the key that is used to store the data.

@Environment(\.passcode.manager) private var passcodeManager

Then simply remove the entry for the passcode

passcodeManager.delete()

PasscodeCore

The core module, that handles displaying the passcode window. By default it has no UI to enter a passcode or setting up and storing the passcode, but you can use this as a base to implement your own UI.

.passcode(mode: PasscodeMode) { dismiss in
    // some Passcode input UI, call `dismiss(animated:)` once finished
} background: {
    // some optional background view
}

Localization

Customize / Localize the PasscodeKit by providing a Passcode.strings file in your main app bundle. See the default Passcode.strings file for English Strings.

Installation

Xcode

Add the following package URL to Xcode

https://github.com/divadretlaw/PasscodeKit

Select the module you need

Xcode

Swift Package Manager

let package = Package(
    dependencies: [
        .package(url: "https://github.com/divadretlaw/PasscodeKit.git", from: "0.7.0")
    ],
    targets: [
        .target(
            name: <#Target Name#>,
            dependencies: [
                .product(name: "PasscodeKit", package: "PasscodeKit")
            ]
        )
    ]
)

License

See LICENSE

Related Skills

View on GitHub
GitHub Stars13
CategoryDevelopment
Updated4mo ago
Forks2

Languages

Swift

Security Score

92/100

Audited on Nov 10, 2025

No findings