For detailed changes, please refer to the Change log.
PasscodeKit is a lightweight and easy-to-use, in-app Passcode implementation for iOS. It includes a custom numeric keypad, optional haptic feedback, and Face ID / Touch ID support.
Swift Package Manager is a tool for managing Swift code distribution.
To add PasscodeKit as a dependency to your project, follow these steps:
- Open your Swift project in Xcode.
- Navigate to
File->Add Package Dependencies.... - Paste
https://github.com/relatedcode/PasscodeKit.gitinto the search bar. - Choose the version you want to use and click
Add Package.
If you prefer not to use the dependency manager above, you can integrate PasscodeKit into your project manually. Simply copy all the *.swift files from the PasscodeKit/Sources folder into your Xcode project.
- iOS 13.0+
To activate the PasscodeKit in your codebase, you need to start it right after the app is launched. The best practice to do it in the AppDelegate didFinishLaunchingWithOptions method.
PasscodeKit.start()The following PasscodeKitDelegate methods can be used to take actions related to the PasscodeKit user activity.
func passcodeCheckedButDisabled()
func passcodeEnteredSuccessfully()
func passcodeMaximumFailedAttempts()To enable, disable the passcode functionality, or to change the saved passcode you can use the following methods.
PasscodeKit.createPasscode(self)
PasscodeKit.changePasscode(self)
PasscodeKit.removePasscode(self)The following settings are available for customizing the passcode-related user experience.
PasscodeKit.passcodeLength = 4
PasscodeKit.allowedFailedAttempts = 3
PasscodeKit.hapticFeedback = truePasscodeKit.textColor = .darkText
PasscodeKit.backgroundColor = .lightGray
PasscodeKit.failedTextColor = .white
PasscodeKit.failedBackgroundColor = .systemRedPasscodeKit.titleEnterPasscode = "Enter Passcode"
PasscodeKit.titleCreatePasscode = "Create Passcode"
PasscodeKit.titleChangePasscode = "Change Passcode"
PasscodeKit.titleRemovePasscode = "Remove Passcode"
PasscodeKit.textEnterPasscode = "Enter your passcode"
PasscodeKit.textVerifyPasscode = "Verify your passcode"
PasscodeKit.textEnterOldPasscode = "Enter your old passcode"
PasscodeKit.textEnterNewPasscode = "Enter your new passcode"
PasscodeKit.textVerifyNewPasscode = "Verify your new passcode"
PasscodeKit.textFailedPasscode = "%d Failed Passcode Attempts"
PasscodeKit.textPasscodeMismatch = "Passcodes did not match. Try again."
PasscodeKit.textTouchIDAccessReason = "Please use Face ID or Touch ID to unlock the app"PasscodeKit supports both Face ID and Touch ID. If you're using Face ID, add an NSFaceIDUsageDescription entry to your Info.plist.
MIT License
Copyright (c) 2026 Related Code
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.