Swiftpack.co - gymshark/ios-card-scan as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by gymshark.
gymshark/ios-card-scan 1.0.5
iOS Credit/Debit card scanner, built using Apple's Vision Framework.
⭐️ 27
🕓 1 year ago
.package(url: "https://github.com/gymshark/ios-card-scan.git", from: "1.0.5")


SharkCardScan is a Credit/Debit Card scanner built using Apple's Vision Framework.

SharkCardScan allows you to quickly implement a card scanner inside of your own app.

SharkCardScan is built and maintained with love by the Gymshark Engineering Team 💙📱


It's possible to get started quickly with the following snippet.

        let scannerVC = SharkCardScanViewController(viewModel: CardScanViewModel(noPermissionAction: { [weak self] in
        }, successHandler: { (response) in
            print("Expiry 💣: \(response.expiry ?? "")")
            print("Card Number 💳: \(response.number)")
            print("Holder name 🕺: \(response.holder ?? "")")

Here we handle the No Camera Permission error, from the ViewModeland our successHandler is called upon receipt of finding a card number, and the expiry and card holders name, albeit, we can call success if only a valid card number is found.


SharkCardScanViewController initialiser takes a default parameter for styling, which you can specify your own, if you wish to amend fonts/colours.

SharkCardScanViewController(viewModel: CardScanViewModel{...}, styling: MyOwnCardScannerStyling())

CardScanStyling is a protocol, your styling struct must conform too with the following properties you have to set;

public protocol CardScanStyling {
    var instructionLabelStyling: LabelStyling { get set }
    var cardNumberLabelStyling: LabelStyling { get set }
    var expiryLabelStyling: LabelStyling { get set }
    var holderLabelStyling: LabelStyling { get set }
    var backgroundColor: UIColor { get set }

NB: By using the default parameter, and using our DefaultStyling struct instance, the font will only have fixed sizes, for now, rather than being dynamic - one for us to fix later (or send us a PR?!)

Other Customisations

ACardScanViewModel has a instructionText property, if you wish to override the default instruction text that is shown on the viewer.


Swift Package Manager (SPM) To install SharkCardScan using Swift Package Manager you can follow the tutorial published by Apple using the URL for the SharkCardScan repo with the current version:

  1. In Xcode, select “File” → “Swift Packages” → “Add Package Dependency”
  2. Enter https://github.com/gymshark/ios-card-scan.git


Stars: 27
Last commit: 4 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics