PasscodeKit

1.2.0

🔐 Easily add a passcode to your iOS app
divadretlaw/PasscodeKit

What's New

1.2.0

2023-10-22T07:10:31Z

What's Changed

  • Check Biometry by-default by @lanserxt in #3
  • Make passcode setup/change transitions configurable
  • Add change passcode view modifier
  • Add multiple passcode types to choose during setup

Full Changelog: 1.1.0...1.2.0

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

Screenshot

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

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

Last updated: Tue Apr 30 2024 00:58:12 GMT-0900 (Hawaii-Aleutian Daylight Time)