Adding the SDK to your project

To add our SDK to your own application, you should add it to the build process of your application. Currently we support doing this using CocoaPods or Carthage.

CocoaPods: Adding the SDK to your Podfile

To add the repository to your project, open the Podfile, if it does not exists, first run pod init in the root of your project with Xcode closed.
Edit the target part of your application in the Podfile, so that it contains the following:

pod 'Klippa-Scanner', podspec: ''

The full Podfile might look like this now:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'TestScanner' do
  # Comment the next line if you don't want to use dynamic frameworks

  # Pods for TestScanner
  pod 'Klippa-Scanner', podspec: ''


When you run pod install now, it should download our library as dependency, and with that all dependencies of our library.
Note: this code always uses the latest version, you can also use a specific version to make sure the SDK won't update without your knowledge.

Carthage: Adding the SDK to your Cartfile

To add the repository to your project, open the Cartfile, if it does not exists, create a Cartfile alongside your .xcodeproj or .xcworkspace.
Add the following to your Cartfile:

binary ""

When you run carthage update now, it should download our library as dependency, and with that all dependencies of our library.
Note: this code always uses the latest version, you can also use a specific version to make sure the SDK won't update without your knowledge.

Starting the scanner

To start the scanner, import our library in your AppDelegate:

// Add to the top of your file
import KlippaScanner

Then init the scanner options inside your launch method, the license is the only required option:

KlippaScanner.setup.license = "replace-with-received-license"

In the controller that you want to launch the scanner, implement the ImageScannerControllerDelegate:

// Add to the top of your file
import KlippaScanner

// Your class definition should look like this.
final class ExampleScannerViewController: UIViewController, ImageScannerControllerDelegate {

    // ... Rest of your controller code.

    func startScanner() {
        let scannerViewController = ImageScannerController()
        scannerViewController.imageScannerDelegate = self
        scannerViewController.modalPresentationStyle = .fullScreen
        present(scannerViewController, animated: false)

    func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error) {
        switch error {
        case let licenseError as LicenseError:
            print("Got licensing error from SDK: \(licenseError.localizedDescription)")

    func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithResult result: ImageScannerResult) {
        // Handle scan results here.
        print("multipleDocumentsModeEnabled \(result.multipleDocumentsModeEnabled)")
        print("Scanned \(result.images.count) images")

    func imageScannerControllerDidCancel(_ scanner: ImageScannerController) {
        scanner.dismiss(animated: true, completion: nil)

    // ... Rest of your controller code.

In the place where you want to start the scanner, for example after a button click, call the startScanner method:


Customizing the scanner

The SDK has a few customizing settings, the following methods are available:

// Whether to show the icon to enable "multi-document-mode"
KlippaScanner.setup.set(allowMultipleDocumentsMode: true)

// Whether the "multi-document-mode" should be enabled by default.
KlippaScanner.setup.set(isMultipleDocumentsModeEnabled: true)

// Ability to disable/hide the shutter button (only works when a model is supplied as well).
KlippaScanner.setup.set(allowShutterButton: true, hideShutterButton: false)

// Whether the crop mode (auto edge detection) should be enabled by default.
KlippaScanner.setup.set(cropEnabled: true)

// Define the max resolution of the output file. It’s possible to set only one of these values. We will make sure the picture fits in the given resolution. We will also keep the aspect ratio of the image. Default is max resolution of camera.
KlippaScanner.setup.imageMaxWidth = 1920
KlippaScanner.setup.imageMaxHeight = 1080

// Set the output quality (between 0-100) of the jpg encoder. Default is 100.
KlippaScanner.setup.imageMaxQuality = 95

// The warning message when someone should move closer to a document, should be a string.
KlippaScanner.setup.moveCloserMessage = "Move closer to the document"

// The warning message when the camera preview has to much motion to be able to automatically take a photo.
KlippaScanner.setup.imageMovingMessage = "Too much movement"

// The warning message when the camera result is too bright.
KlippaScanner.setup.imageTooBrightMessage = "The image is too bright"

// The warning message when the camera result is too dark.
KlippaScanner.setup.imageTooDarkMessage = "The image is too dark"

// The primary color of the interface, should be a UIColor.
KlippaScanner.setup.primaryColor = UIColor(red: 0.153, green: 0.733, blue: 0.373, alpha: 1.00)

// The accent color of the interface, should be a UIColor.
KlippaScanner.setup.accentColor = UIColor(red: 0.153, green: 0.733, blue: 0.373, alpha: 1.00)

// The overlay color (when using document detection), should be a UIColor.
KlippaScanner.setup.overlayColor = UIColor(red: 0.17, green: 0.77, blue: 0.41, alpha: 1.00)

// The color of the background of the warning message, should be a UIColor.
KlippaScanner.setup.warningBackgroundColor = .red

// The color of the text of the warning message, should be a UIColor.
KlippaScanner.setup.warningTextColor = .white

// The color of the menu icons when they are enabled, should be a UIColor.
KlippaScanner.setup.iconEnabledColor = .white

// The color of the menu icons when they are disabled, should be a UIColor.
KlippaScanner.setup.iconDisabledColor = .gray

// The color of the menu icons of the screen where you can review/edit the images, should be a UIColor.
KlippaScanner.setup.reviewIconColor = .white

// The amount of opacity for the overlay, should be a float.
KlippaScanner.setup.overlayColorAlpha = 0.75

// The amount of seconds the preview should be visible for, should be a float.
KlippaScanner.setup.previewDuration = 1.0

// Whether the camera has a view finder overlay (a helper grid so the user knows where the document should be), should be a Boolean.
KlippaScanner.setup.isViewFinderEnabled = true

// If you would like to use a custom model for object detection. Model + labels file should be packaged in your bundle.
KlippaScanner.setup.set(modelName: "model", modelLabelsName: "labels")

// If you would like to enable automatic capturing of images.
KlippaScanner.setup.isTimerEnabled = true
KlippaScanner.setup.timerDuration = 0.5

// To add extra horizontal and / or vertical padding to the cropped image.
KlippaScanner.setup.set(cropPadding: CGSize(width: 100, height: 100))

// After capture, show a checkmark preview with this success message, instead of a preview of the image.
KlippaScanner.setup.set(successMessage: "Success!", successPreviewDuration: 0.3)

// Whether the camera automatically saves the images to the camera roll. Default true. (iOS version 0.4.2 and up only)
KlippaScanner.setup.storeImagesToCameraRoll = true

// The threshold sensitive the motion detection is. (lower value is higher sensitivity, default 200).
KlippaScanner.setup.imageMovingSensitivity = 200

Calling the OCR API

It's possible to use the results of the scanner with the OCR API.

To use it, generate a Public API key with our API through your own backend, this makes sure your API key won't be leaked and/or abused.

Edit your Podfile file, so that it contains the following:

pod 'Klippa-OCR-API', podspec: ''

If you are using Carthage, add the folowing to your Cartfile:

binary ""

You then have the possibility to call the OCR API client and run it on the images of the scanner.
The following example runs the OCR on every image and then shows the total amount.


import UIKit
import KlippaScanner
import KlippaOCRAPI

final class ViewController: UIViewController, ImageScannerControllerDelegate {

    private var loadedScanner = false
    private var totalAmount: Float64 = 0
    private var vSpinner : UIView?

    override func viewDidLoad() {

    override func viewWillAppear(_ animated: Bool) {

        if (!loadedScanner) {
            loadedScanner = true
            let scannerViewController = ImageScannerController()
            scannerViewController.imageScannerDelegate = self
            scannerViewController.modalPresentationStyle = .fullScreen
            present(scannerViewController, animated: false)

    func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error) {
        switch error {
        case let licenseError as LicenseError:
            print("Got licensing error from SDK: \(licenseError.localizedDescription)")

    func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithResult result: ImageScannerResult) {
        print("multipleDocumentsModeEnabled \(result.multipleDocumentsModeEnabled)")
        print("Scanned \(result.images.count) images")
        totalAmount = 0

        let publicAPIKey = ""
        var processedImages = 0
        self.showSpinner(onView: self.view)

        for image in result.images {
            print ("Scanning image \(image.path)")

            let url = URL.init(fileURLWithPath: image.path.replacingOccurrences(of: "file://", with: ""))

            ParsingAPI.parseDocumentWithRequestBuilder(document: url, url: nil, template: nil, pdfTextExtraction: ParsingAPI.PdfTextExtraction_parseDocument(rawValue: "full"), userData: nil, userDataSetExternalId: nil, hashDuplicateGroupId: nil).addHeader(name: "X-Auth-Public-Key", value: publicAPIKey).execute { (response) in

                do {
                    let receipt = try response.get().body
                    if receipt?.data?.amount != nil {
                        self.totalAmount += Float64((receipt?.data?.amount)!) / 100
                } catch(let e) {
                    if let err = e as? ErrorResponse {
                        case ErrorResponse.error(let code, let body, _, _):

                            if body != nil {
                                print(String.init(bytes: body!, encoding: String.Encoding.utf8)!)

                        @unknown default:
                            print("Unknown error")

                processedImages += 1
                if processedImages == result.images.count {

    func showSpinner(onView : UIView) {
         let spinnerView = UIView.init(frame: onView.bounds)
         spinnerView.backgroundColor = UIColor.init(red: 0.5, green: 0.5, blue: 0.5, alpha: 0.5)
         let ai = UIActivityIndicatorView.init(style: .whiteLarge)
         ai.startAnimating() =

         DispatchQueue.main.async {

         vSpinner = spinnerView

    func removeSpinner() {
         DispatchQueue.main.async {
            self.vSpinner = nil

    func finishedOCRProcessing() {

        let alert = UIAlertController(title: "Scans finished", message: "The total amount of all images is \(totalAmount)", preferredStyle: .alert)
        self.present(alert, animated: true, completion: nil)

    func imageScannerControllerDidCancel(_ scanner: ImageScannerController) {
        scanner.dismiss(animated: true, completion: nil)



The following versions are available:

Version Podspec include URL Cartfile dependency Binary download
0.5.1 binary "" == 0.5.1 Fat framework (.xcarchive) | XCFramework
0.5.0 binary "" == 0.5.0 Fat framework (.xcarchive) | XCFramework
0.4.12 binary "" == 0.4.12 Fat framework (.xcarchive) | XCFramework
0.4.11 binary "" == 0.4.11 Fat framework (.xcarchive) | XCFramework
0.4.10 binary "" == 0.4.10 Fat framework (.xcarchive) | XCFramework
0.4.9 binary "" == 0.4.9 Fat framework (.xcarchive) | XCFramework
0.4.8 binary "" == 0.4.8 Fat framework (.xcarchive) | XCFramework
0.4.7 binary "" == 0.4.7 Fat framework (.xcarchive) | XCFramework
0.4.6 binary "" == 0.4.6 Fat framework (.xcarchive) | XCFramework
0.4.5 binary "" == 0.4.5 Fat framework (.xcarchive) | XCFramework
0.4.4 binary "" == 0.4.4 Fat framework (.xcarchive) | XCFramework
0.4.3 binary "" == 0.4.3 Fat framework (.xcarchive) | XCFramework
0.4.2 binary "" == 0.4.2 Fat framework (.xcarchive) | XCFramework
0.3.4 binary "" == 0.3.4 Fat framework (.xcarchive) | XCFramework
0.3.3 binary "" == 0.3.3 Fat framework (.xcarchive) | XCFramework
0.3.2 binary "" == 0.3.2 Fat framework (.xcarchive) | XCFramework
0.3.1 binary "" == 0.3.1 Fat framework (.xcarchive) | XCFramework
0.3.0 binary "" == 0.3.0 Fat framework (.xcarchive) | XCFramework
0.2.0 binary "" == 0.2.0 Fat framework (.xcarchive) | XCFramework
0.1.4 binary "" == 0.1.4 Fat framework (.xcarchive) | XCFramework
0.1.3 binary "" == 0.1.3 Fat framework (.xcarchive) | XCFramework
0.1.2 binary "" == 0.1.2 Fat framework (.xcarchive) | XCFramework
0.1.1 binary "" == 0.1.1 Fat framework (.xcarchive) | XCFramework
0.1.0 binary "" == 0.1.0 Fat framework (.xcarchive) | XCFramework
0.0.14 binary "" == 0.0.14 Fat framework (.xcarchive) | XCFramework
0.0.13 binary "" == 0.0.13 Fat framework (.xcarchive) | XCFramework
0.0.12 binary "" == 0.0.12 Fat framework (.xcarchive) | XCFramework
0.0.11 binary "" == 0.0.11 Fat framework (.xcarchive) | XCFramework
0.0.10 binary "" == 0.0.10 Fat framework (.xcarchive) | XCFramework
0.0.8 binary "" == 0.0.8 Fat framework (.xcarchive) | XCFramework
0.0.7 binary "" == 0.0.7 Fat framework (.xcarchive) | XCFramework
0.0.6 binary "" == 0.0.6 Fat framework (.xcarchive) | XCFramework
0.0.5 binary "" == 0.0.5 Fat framework (.xcarchive) | XCFramework
0.0.4 binary "" == 0.0.4 Fat framework (.xcarchive) | XCFramework
0.0.2 binary "" == 0.0.2 Fat framework (.xcarchive) | XCFramework




  • Issue where zoomed image on edit screen had incorrect orientation.



  • Ability to automatically go to the review screen once the image limit has been reached by setting shouldGoToReviewScreenWhenImageLimitReached (default false).
  • Ability to hide top navigation bar buttons by setting: userCanRotateImage, userCanCropManually, userCanChangeColorSetting accordingly (each default true).
  • Deleting an image now prompts an alert to confirm your action. Texts can be set with: deleteButtonText, retakeButtonText, cancelButtonText.
  • Ability to cancel the scanner completely on the review screen by pressing cancel, texts can be set with: cancelAndDeleteImagesButtonText, cancelConfirmationMessage.
  • Users can now complete scan process from the review screen by pressing “>” button.


  • Issue where scanner could stop working unexpectedly due to memory running out.



  • Issue where users could take more pictures than the specified image limit.


  • Support for longer receipts.


  • Default max image resolutions from 1000 to 3000.
  • Now imageMovingMessage only shows when we have detected an object.



  • Issue where device could run out of memory with high resolution images.



  • Ability to limit amount of pictures that can be taken with imageLimit and set a message once limit has been reached with imageLimitReachedMessage.


  • Done button will now automatically use correct localization.



  • Ability to hide timer button by setting KlippaScanner.setup.set(allowTimer: false)



  • arm64 build for simulator to add support for M1 Macs. Please note that this only work in XCFrameworks (CocoaPods), and not in the fat framework, since you can only have one arm64 binary, and the device binaries already come with an arm64 binary.



  • When scanning with a model the scanner no longer requires you to supply the Bundle.



  • Ability to disable/hide the shutter button. KlippaScanner.setup.set(allowShutterButton: false, hideShutterButton: false)
  • Ability to adjust the sensitivity of the motion detection, lower values give higher sensitivity. KlippaScanner.setup.set(imageMovingSensitivity: 200)



  • Issue where padding was being set incorrectly with document scanning.


  • Default colors are now default Klippa colors.



  • Issue when setting up with Carthage.



  • Functionality when timer is enabled scanner will not automatically take photos if too much movement is detected.
  • Optionally add user indication when movement is detected. KlippaScanner.setup.set(imageMovingMessage: "Too much movement")



  • Issue where scanner failed to reinitialize.
  • Issue where storing enhanced images sometimes caused memory to run out.


  • Ability to disable saving to camera roll with following method KlippaScanner.setup.set(storeImagesToCameraRoll: false).



  • Issue where images did not load in React Native.
  • Issue where path was not returned correctly from scanner in React Native.


  • Helper method retrieve(path: "pathToImage", from directory: .documents, as type: UIImage.self) to retrieve image from provided path.



  • Important: Scanner now only returns a path to image in documents instead of also a UIImage (see next bullet point for reasoning).
  • Taken images are now no longer stored in device memory but in temporary storage.
  • Fixed multiple memory leaks.



  • Issue related to implementing the SDK directly in a Swift project.



  • Added default extension for model and labelmap file.



  • Added default value for crop padding: CGSize(0, 0)



  • Fixed the overlay color not being correctly restored.



  • Added the ability to recognize custom objects (instead of documents) using a trained TensorFlow Lite model. Klippa can train these custom models for whatever you like to capture using the KlippaScanner SDK.
  • Model can be supplied by using the setup method KlippaScanner.setup.set(modelName: "model", modelLabelsName: "labels", modelBundleLocation: ViewController.self)
  • A timer has been added, to automatically capture recognized objects after a certain time has elapsed: KlippaScanner.setup.set(isTimerEnabled: true) and KlippaScanner.setup.set(timerDuration: 0.5)
  • A success message with checkmark icon can be shown instead of a preview of the captured image using KlippaScanner.setup.set(successMessage: "Success!", successPreviewDuration: 0.3)
  • When capturing using a model, padding can be added to the cropped area using KlippaScanner.setup.set(cropPadding: CGSize(width: 200, height: 200)) (this example adds 100px cropping to the left, right, top and bottom of the image).



  • Build using XCode 12/Swift 5.3



  • The ImageScannerResult object returned in didFinishScanningWithResult now also contains the cropEnabled variable, indicating the status of the crop button.



  • A back button has been added in the bottom left corner. It’s visible as long as no photo’s have been taken yet. Pressing the back button dismisses the view controller and calls imageScannerControllerDidCancel on the delegate.



  • The build system has now been changes to the modern build system, and we now build the library with the option BUILD_LIBRARY_FOR_DISTRIBUTION. We also use XCFrameworks now to package the framework. The Carthage package still links to the traditional fat framework because Carthage does not support XCFramework yet, but the framework is now based on the files from the XCFramework package.



  • The isMultipleDocumentsModeEnabled option has been added to make a distinction between the multiple documents mode being available at all, and the user toggling the button. allowMultipleDocumentsMode now displays / hides the button whilst isMultipleDocumentsModeEnabled toggles the initial state when the button is visible.



  • Fix image preview when cropping pictures that have been taken in landscape.



  • The primaryColor is now used for the toolbar.
  • The accentColor is used for controls.
  • The overlayColor is used for both the area that will be cropped and the cropping controls.
  • The isAutoScanEnabled and isAutoScanEnabled options have been removed.
  • Reduced the duration of capture animations.
  • The colors for the crop, multiple documents mode and flash toggles have been changed to partially white (disabled state) and fully white (enabled state).


  • Pressing the crop-button no longer takes a photo.
  • Fixed inconsistent behavior of isCropEnabled option.
  • Changes to the cropped area were not saved when returning to the camera.
  • The orientation of landscape photos changed to black-white was incorrect.
  • The initial state for allowMultipleDocumentsMode was being ignored.
  • Rotating the photo now also rotates the original picture and not just the cropped area. The cropped area will also be properly rotated.



  • Added default constructor for ImageScannerController.


  • ImageScannerControllerDelegate now finishes scanning with one object (ImageScannerResult), containing the captured images and the multipleDocumentsModeEnabled property.
  • Added classname to the @objc decorator, to enable Nativescript to discover the correct classes on run time.



  • Added default constructor for ImageScannerController.


  • Corrected some typo’s (imageTooDarkMessage, imageTooBrightMessage).



  • Combine Swift headers for all archs.



  • Lower deployment target in Podspec from 11.0 to 10.0.



  • Lower deployment target from 11.0 to 10.0.


  • Minor bugfixes



  • Properties of KlippaImage were missing public acccess.



  • Added multiple documents mode (allowMultipleDocumentsMode in KlippaScanner).
  • Added max width, height and quality constraints (imageMaxWidth, imageMaxHeight and imageMaxQuality in KlippaScanner).
  • Added ability to customize the warning text color (warningTextColor in KlippaScanner).


  • Renamed project from KippaScanner to KlippaScanner.
  • KlippaImage results now also returns the output path (path property in KlippaImage).
  • Lower deployment target from 11.2 to 11.0.


  • Clicking the hidden thumbnails button without pictures crashed the camera.
  • Auto scan triggering directly after enabling.



  • Export more members to Object C for use in projects like NativeScript and React Native.



  • Updated podspec file to match deployment target.



  • Fix UILabel padding extension.