Simple & Fast Card Scanner Library for SwiftUI

Smartcard scanner

SweetCardScanner is a fast and simple card scanner library, written in Swift format, based on @yhkaplan’s CreditCardScanner and Reg libraries, making it much easier for users to pay with a credit/debit card using the reversing camera.


  • iOS 13.0+ (thanks to SwiftUI, Vision Framework)
    • Tested on iOS 14.1 with iPhone X


  • In Xcode, add SwiftPM from the URL of this repository:


  1. Add NSCameraUsageDescription to Info.plist to describe the use of the camera.
  2. Import SweetCardScanner via
  3. You can now use it as a SweetCardScanner() in your body.
  4. You can also use completion clouds such as .onDismiss, .onError, .onSuccess directly after SweetCardScanner(), as shown below.
  5. If you want to turn off the camera when viewing the results, you must use your own trick with the navigation status settings. (Look at the example below)

var body: what Image {SweetCardScanner().onDismiss {// Do something when the image is closed.}.onError {error // The error above gives you the CreditCardScannerError structure below.expression (error)}.onSuccess { Card in/// The card above gives you the CreditCard structure below.

Error in credit card scanner

the public institution CreditCardScannerError : LocalizedError {
public enum Art {Camera Setup, Editing, Permission Objection, Recording }
public brew : Public version
, underlying error : A mistake?
Incorrect description of the public variation : Thong? {(underlying error such as? Localized error)?.ErrorDescription }

Credit card

public structure credit card {public wagon number : Cord? Name of the public Var
: Thong?
public var expiresDate : DateComponents?


You can customize your own view with SweetCardScanner and SwiftUI as shown below.

Input SwiftUI
SweetCardScanner input

to structure ContentView: See {

@State var navigationStatus : Navigation status ? = .ready
@state var map : A credit card?


var body : some view {

Navigation view

GeometryReader {Geometry in


destination: ResultView(map: map)
.onDisappear {
You can reactivate camera
when you return to this view from ResultView
by changing your own customizable navigation status.
self.navigationStatus = .ready
}, tag
: NavigationStatus.pop, choose
: $navigationStatus) {

You can turn off the camera when viewing the
result using the f-statement below.
as navigationStatus == .ready {
.onError { error in
.onSuccess { card in
self-.card = card
self-.navigationStatus = .pop

Rounded rectangle (cornerRadius: 16)
.frame(width: geometry.size.width, height: geometry.size.width * 0.63, size.width, alignment: .centre)

} // : ZACK




// MARK: –
enum Navigation status {
Home ready, doll


Related Tags:

smart lock location not working reddit,smart lock not working s10,android cannot add trusted device,smart lock greyed out,android trusted site,android phone not locking,trusted places note 10,smart lock face unlock not working,galaxy s9 smart lock,google smart lock glitch,samsung smart door lock not working,turn on smart lock,smart lock is garbage,trusted places s10,smart lock trusted places not working 2020,chromebook smart lock not working 2020,chromebook smart unlock not working,galaxy note 8 smart lock problem,smart lock trusted places not working 2019,smart lock trusted devices not working,android smart lock trusted devices not working,smart lock not working android 10,android 10 smart lock problems,smart lock trusted places not working s10,android smart lock bluetooth not working