SCTqrScanner 1.1.0

SCTqrScanner 1.1.0

Maintained by Geza Csiki.



  • By
  • Geza Csiki

Logo

SCTqrScanner

The SCTqrScanner read special QR codes created for SEPA Credit Transfer. After scan the reader returns the info from QR in special SCTqrResult. This Result contains the name and the IBAN (Mandatory fileds), bic, amount, purpose, remittance or reference, which are optional fields

xCode Swift License Platform Carthage compatible

Requirements

  • iOS 10.0+
  • Xcode 10.1+
  • Swift 4.2+

Screens

Screen2 Screen3 Screen4

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate SCTqrScanner into your xCode project using CocoaPods, specify it in your Podfile:

pod 'SCTqrScanner'

Install into your project:

$ pod install

Open your project in xCode from the .xcworkspace file (not the usual project file):

$ open MyProject.xcworkspace

You can now import SCTqrScanner framework into your files.

Carthage

  1. Get Carthage by running brew install carthage
  2. Create a Cartfile in the same directory where your .xcodeproj or .xcworkspace is
touch Cartfile
  1. List the desired dependencies in the Cartfile, for example:
gitHub "csikigeza/SCTqrScanner"
  1. Run carthage update
  2. A Cartfile.resolved file and a Carthage directory will appear in the same directory where your .xcodeproj or .xcworkspace is
  3. Drag the built .framework binaries from Carthage/Build/<platform> into your application’s Xcode project.
  4. On your application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:
/usr/local/bin/carthage copy-frameworks
  • Add the paths to the frameworks you want to use under “Input Files". For example:
$(SRCROOT)/Carthage/Build/iOS/SCTqrScanner.framework
  • Add the paths to the copied frameworks to the “Output Files”. For example:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SCTqrScanner.framework

Usage

Since iOS10+, you will need the permision from user for the camera usage. For that you will need to add the Privacy - Camera Usage Description (NSCameraUsageDescription) field in your Info.plist file.

Create your own codeReader and videoLayer properties on the ViewController on which you want to use the SCTqrScanner.

private var codeReader = SCTqrScanner()
private var videoLayer: CALayer!

Also you need a IBOutlet for the camera preview:

@IBOutlet weak var videoPreview: UIView!

Start the SCTqrScanner in viewWillAppear and handl the response.

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    codeReader.startReading { [weak self] (qrResult) in
            //TODO: use response
    }
}

The qrResult can be nil, if the QR does not conform to the SEPA Credit Transfer Standards defined from European Payments Council (See SCT Standards). Otherwise the respons has SCTqrResult type.

SCTqrResult contains obligatory the name and iban.

Assign the Camera preview to your view in viewDidload:

override func viewDidLoad() {
    super.viewDidLoad()
    videoLayer = codeReader.videoPreview
    videoPreview.layer.addSublayer(videoLayer)
}

License

SCTqrScanner is released under the MIT license. See LICENSE for details.