Skip to main content

Quick Start

In this quick guide you will learn how to integrate the Veryfi Lens for Mobile iOS SDK into iOS apps for Receipts processing.

Prerequisites

  • API credentials (more info: Authentication)
  • Xcode project with CocoaPods or Swift Package Manager
  • iOS 12.1 or later
  • CocoaPods installed (if using CocoaPods method)

1. Obtaining Credentials

You need two sets of credentials:

  • Access credentials to download the SDK (CocoaPods username and password)
  • API credentials to access the Veryfi API (Client ID, API key, username, URL)

If you don't have an account with Veryfi, please register here: https://app.veryfi.com/signup/api/

In the Veryfi hub, go to https://app.veryfi.com/api/settings/keys/:

  • In the API Auth Credentials section, you can get your API credentials
  • In the Lens: Cocoapods (iOS) section, click the "Add Access Key" button to create your access credentials
    • Fill in: First Name, Last Name, Email
    • The system will generate your username and password automatically
    • Save your generated username and password

2. iOS Installation

Option A: CocoaPods Installation

  1. Store Cocoapods Access Credentials with Git Credential Tool (Recommended):
git credential approve <<EOF
protocol=https
host=repo.veryfi.com
path=shared/lens/veryfi-lens-podspec.git
username=COCOAPODS_USERNAME
password=COCOAPODS_PASSWORD
EOF
  1. Update your Podfile:
source 'https://repo.veryfi.com/shared/lens/veryfi-lens-podspec.git'
source 'https://github.com/CocoaPods/Specs.git'

target 'YourApp' do
use_frameworks!
pod 'VeryfiLens', '~> 2.2.33.4' # Replace with latest version
end
  1. Install the SDK:
pod repo update
pod install
  1. Open the workspace: Always use the .xcworkspace file, not the .xcodeproj file

Option B: Swift Package Manager Installation

  1. Store SPM Access Credentials with Git Credential Tool:
git credential approve <<EOF
protocol=https
host=repo.veryfi.com
path=shared/lens/veryfi-lens-spm.git
username=COCOAPODS_USERNAME
password=COCOAPODS_PASSWORD
EOF
  1. In Xcode: File → Add Package Dependencies

  2. Enter package URL: https://repo.veryfi.com/shared/lens/veryfi-lens-spm.git

  3. Enter credentials: Use the same credentials created for CocoaPods (COCOAPODS_USERNAME and COCOAPODS_PASSWORD)

  4. Select version:

    • For latest version: Choose Dependency Rule Branch and set value to master
    • For specific version:
  5. Wait for Xcode to download the source and that's it, the package is installed

  6. To resolve via terminal after adding the dependency in your project, store your credentials as follows:

git credential approve <<EOF
protocol=https
host=repo.veryfi.com
path=shared/lens/veryfi-lens-spm.git
username=COCOAPODS_USERNAME
password=COCOAPODS_PASSWORD
EOF
note

After adding the dependency in your project. Running xcodebuild -resolvePackageDependencies will not fail in your pipeline

3. iOS Project Configuration

  1. Update Build Settings:
    • Enable Bitcode: NO
    • Validate Workspace: YES
note

If you're using Xcode 14 or above you may not need to update these settings, since these are now deprecated

  1. Add required permissions:

Option A: Using Info.plist file (if it exists):

<key>NSCameraUsageDescription</key>
<string>Scan documents</string>

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Back up your document images in your photo gallery</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>Choose document images to process from your photo gallery</string>

Option B: Using Xcode UI (if no Info.plist exists):

  1. Select your project in the navigator
  2. Select your target
  3. Go to the "Info" tab
  4. Add the following keys by clicking the "+" button:
    • Privacy - Camera Usage Description (NSCameraUsageDescription) = "Scan documents"
    • Privacy - Photo Library Additions Usage Description (NSPhotoLibraryAddUsageDescription) = "Back up your document images in your photo gallery"
    • Privacy - Photo Library Usage Description (NSPhotoLibraryUsageDescription) = "Choose document images to process from your photo gallery"

4. iOS Initialization

  1. Import the SDK:
import VeryfiLens
  1. Configure your authentication credentials: Get your API credentials from https://app.veryfi.com/api/settings/keys/ → API Auth Credentials section:
let CLIENT_ID = "XXX" // replace XXX with your assigned Client Id
let AUTH_USERNAME = "XXX" // replace XXX with your assigned Username
let AUTH_APIKEY = "XXX" // replace XXX with your assigned API Key
let URL = "XXX" // replace XXX with your assigned Endpoint URL

let veryfiLensCredentials = VeryfiLensCredentials(clientId: CLIENT_ID,
username: AUTH_USERNAME,
apiKey: AUTH_APIKEY,
url: URL)
  1. Configure your Veryfi Lens settings for Receipts:

Option A: Using predefined Receipts settings (Recommended):

let veryfiLensSettings = VeryfiLensReceiptsSettings()

Option B: Using custom settings: Use VeryfiLensSettings() for complete custom configuration. Check available document types at https://docs.veryfi.com/lens/mobile/settings/#documenttypes:

let veryfiLensSettings = VeryfiLensSettings()
veryfiLensSettings.autoRotateIsOn = true
veryfiLensSettings.autoSubmitDocumentOnCapture = false
veryfiLensSettings.documentTypes = ["receipt"]
veryfiLensSettings.galleryIsOn = true
veryfiLensSettings.moreMenuIsOn = true

Available settings classes:

  • VeryfiLensSettings() - Global settings class for complete custom configuration
  • VeryfiLensReceiptsSettings() - Predefined settings optimized for receipt processing
  • VeryfiLensChecksSettings() - Predefined settings optimized for check processing
  1. Implement the delegate:
extension ViewController: VeryfiLensDelegate {
func veryfiLensClose(_ json: [String : Any]) { /* handle */ }
func veryfiLensError(_ json: [String : Any]) { /* handle */ }
func veryfiLensSuccess(_ json: [String : Any]) { /* handle */ }
func veryfiLensUpdate(_ json: [String : Any]) { /* handle */ }
}
  1. Initialize the SDK:
VeryfiLens.shared().configure(with: veryfiLensCredentials, 
settings: veryfiLensSettings) { success in
if success {
// SDK configured successfully
}
}
  1. Launch the camera:
VeryfiLens.shared().showCamera(in: self)

5. Full iOS Examples

UIKit Example: ViewController.swift

import UIKit
import VeryfiLens

class ViewController: UIViewController, VeryfiLensDelegate {

override func viewDidLoad() {
super.viewDidLoad()
setupVeryfiLens()
}

private func setupVeryfiLens() {
// Configure credentials
let CLIENT_ID = "CLIENT_ID"
let AUTH_USERNAME = "USERNAME"
let AUTH_APIKEY = "API_KEY"
let URL = "URL"

let veryfiLensCredentials = VeryfiLensCredentials(clientId: CLIENT_ID,
username: AUTH_USERNAME,
apiKey: AUTH_APIKEY,
url: URL)

// Configure settings
let veryfiLensSettings = VeryfiLensReceiptsSettings() // Predefined settings optimized for receipts

// Set delegate and configure
VeryfiLens.shared().delegate = self
VeryfiLens.shared().configure(with: veryfiLensCredentials,
settings: veryfiLensSettings) { success in
if success {
print("Veryfi Lens configured successfully")
}
}
}

@IBAction func openCamera(_ sender: Any) {
VeryfiLens.shared().showCamera(in: self)
}

// MARK: - VeryfiLensDelegate

func veryfiLensClose(_ json: [String : Any]) {
print("Lens closed: \(json)")
}

func veryfiLensError(_ json: [String : Any]) {
print("Lens error: \(json)")
}

func veryfiLensSuccess(_ json: [String : Any]) {
print("Lens success: \(json)")
// Process the extracted receipt data here
}

func veryfiLensUpdate(_ json: [String : Any]) {
print("Lens update: \(json)")
}
}

SwiftUI Example: ContentView.swift

import SwiftUI
import VeryfiLens

struct ContentView: View {
@StateObject private var lensManager = LensManager()

var body: some View {
VStack {
Button("Scan Receipt") {
lensManager.showCamera()
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
}
.onAppear {
lensManager.setupVeryfiLens()
}
}
}

class LensManager: NSObject, ObservableObject, VeryfiLensDelegate {

func setupVeryfiLens() {
// Configure credentials
let CLIENT_ID = "CLIENT_ID"
let AUTH_USERNAME = "USERNAME"
let AUTH_APIKEY = "API_KEY"
let URL = "URL"

let veryfiLensCredentials = VeryfiLensCredentials(clientId: CLIENT_ID,
username: AUTH_USERNAME,
apiKey: AUTH_APIKEY,
url: URL)

// Configure settings
let veryfiLensSettings = VeryfiLensReceiptsSettings() // Predefined settings optimized for receipts

// Set delegate and configure
VeryfiLens.shared().delegate = self
VeryfiLens.shared().configure(with: veryfiLensCredentials,
settings: veryfiLensSettings) { success in
if success {
print("Veryfi Lens configured successfully")
}
}
}

func showCamera() {
// Get the current window scene
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first {
VeryfiLens.shared().showCamera(in: window.rootViewController!)
}
}

// MARK: - VeryfiLensDelegate

func veryfiLensClose(_ json: [String : Any]) {
print("Lens closed: \(json)")
}

func veryfiLensError(_ json: [String : Any]) {
print("Lens error: \(json)")
}

func veryfiLensSuccess(_ json: [String : Any]) {
print("Lens success: \(json)")
// Process the extracted receipt data here
}

func veryfiLensUpdate(_ json: [String : Any]) {
print("Lens update: \(json)")
}
}