Skip to main content

iOS Document Scanner SDK - Getting Started

Requirements

Minimum deployment target: iOS 13.0

Supported architectures:

  • XCFramework (Download, Cocoapods, SPM): iPhoneOS arm64, iPhoneSimulatorOS arm64 and x86_64
  • Framework (Download): iPhoneOS arm64 and iPhoneSimulatorOS x86_64

Bitcode is no longer supported by Apple and has therefore been removed from Scanbot SDK

Compatible programming languages: Objective-C and Swift

Variations

Scanbot SDK comes in 2 different variations, each having different features and size:

  • ScanbotSDK (fully featured including Document Scanning, Barcode Scanning, Generic Document Scanning, Check Scanning, OCR, PDF Creation etc.)
  • ScanbotDocumentScannerSDK (document scanning only)

Use ScanbotDocumentScannerSDK if you only need document scanning and want to minimize your apps size. Use ScanbotSDK if you need access to all features.

Distribution

Both variations are available as an XCFramework, as a static framework (deprecated), via Swift Package Manager (SPM) and via Cocoapods.

Please note

Use one of the XCFrameworks if possible. XCFrameworks contain all supported architectures and are thinned automatically when uploading your app to appstoreconnect.com. Frameworks are deprecated, due to their inability to run natively on Apple Silicon simulators. When uploading your app to appstoreconnect.com you must strip the framework's x86_64 architecture.

ScanbotSDK and ScanbotDocumentScannerSDK are both published via

Installation

Please note

The installation guides refer to the full ScanbotSDK variation. If you want to use the ScanbotDocumentScannerSDK variation please replace 'ScanbotSDK' with 'ScanbotDocumentScannerSDK' and skip the additional data bundle steps.

For text recognition, additional data bundles are required in your project. You can include these bundles by adding them to your app's bundle.

Installation using CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C projects for macOS as well as iOS. It integrates deeply into your Xcode project and manages the third-party components in your app.

  1. If not already done, install CocoaPods on your Mac
  2. Add pods to your Xcode project as described in this guide
  3. Modify your podfile to include ScanbotSDK as described here

Open your podfile in Xcode or with any text editor and add the following line:

pod 'ScanbotSDK'

Your podfile should now read as follows:

target 'SDKPodTest' do
use_frameworks!
pod 'ScanbotSDK'
end

Save the podfile and run the following command in your project's folder using the macOS Terminal:

$ pod install

Open your application's Xcode workspace (not the project file) - you should now be able to use the Scanbot SDK in your project.

Additional data bundles (ScanbotSDK only)

For some Scanbot SDK features you will require additional data bundles. These bundles are contained in the pod but, by default, they are not added to your application's bundle.

To use these additional bundles edit your podfile and add one or more of the following subspecs to the Scanbot SDK pod:

  • For optical Text recognition: [OCR]
  • For all features: [ALL]

Your podfile should now look similar to this:

target 'SDKPodTest' do
use_frameworks!
pod 'ScanbotSDK', :subspecs => ['OCR']
end

When using all subspecs:

target 'SDKPodTest' do
use_frameworks!
pod 'ScanbotSDK', :subspecs => ['ALL']
end

Whenever you change your podfile you must update the pods using the following command in your project's folder using the macOS Terminal:

$ pod update
Hint

Do not use subspecs if not needed, the additional bundles will enlarge your app's file size by a good amount.

caution

CocoaPods version >= 1.5 is required to handle subspec-switching correctly.

Installation via Swift Package Manager

The Scanner SDK provides the ability to be integrated into your app via the Swift Package Manager (more about Swift Packages).

Installation guide

Step 1: Add the package Add Packages

Install additional OCR data bundle if needed (Swift Package Manager, ScanbotSDK only)

Step 1: Add a new target for the copy script Add New Target

  • Navigate to the project's settings and click the + button in the bottom left corner to add a new target.
  • In the target's template menu, navigate to Other, select Aggregate and click Next.
  • Name the new target, e.g. Copy Bundles, and click Finish.

Step 2: Add the copy script Add Script

  • Navigate to the newly created target's Build Phases, click the + button in the top left corner and select New Run Script Phase.
  • Copy this script to the editor:
cp -af "${BUILD_DIR%Build/*}/SourcePackages/checkouts/scanbot-sdk-ios-spm/Sources/AdditionalData/ScanbotSDKOCRData.bundle" "${PROJECT_DIR}/"
  • Navigate to the newly created target's Build Settings, find ENABLE_USER_SCRIPT_SANDBOXING and set it to NO. (Xcode 15 and later)
info

This script automatically copies additional bundles from the temporary package directory to your project's main directory.

Step 3: Add a dependency Add Dependency

  • Navigate to ScanbotSDK-Setup -> Build Phases and add the newly created target as a dependency.
  • Run the project.

Step 4: Add bundles to a Project Add Bundles to Xcode In the Finder, navigate to the project's folder and drag ScanbotSDKOCRData.bundle into Xcode, confirm ScanbotSDK-Setup target is checked and click Finish.

Installation as an embeddable XCFramework (XCode 11+ only)

Installing the Scanbot SDK embedded XCFramework is similar to using the framework, except for the strip script which is not needed with XCFrameworks. Check out our step-by-step guide.

  1. Extract the donwloaded ZIP file and copy the extracted folder into your app's project folder
  2. Open your app project in Xcode
  3. Select your app's build target and drag the XCFramework into it
  4. Optional, ScanbotSDK only: add the data bundle for OCR to your project as needed. See here
  5. Import the framework's umbrella header in your source code files:
`#import <ScanbotSDK/ScanbotSDK.h>`

or

`@import ScanbotSDK;`

Step-by-step XCFramework installation guide

Step 1 Copy the folder containing the downloaded XCFramework into your apps project folder Copy the folder containing the downloaded XCFramework into your app's project folder.

Step 2 Open your app project in Xcode Open your app project in Xcode.

Step 3 Drag the XCFramework into your project. Navigate into the SDK folder and drag the XCFramework into your project's 'Frameworks, Libraries and Embedded Content' section.

Step 4 Install the additional data bundles if required.

Installation as an embeddable framework

Check out our step-by-step guide.

  1. Extract the donwloaded ZIP file and copy the extracted folder into your app's project folder
  2. Open your app project in Xcode
  3. Select your app's build target and drag the framework into it
  4. Add a runscript build phase to strip out simulator architectures from the SDK
  5. Optional: add the data bundle for OCR to your project as needed
  6. Import the framework's umbrella header in your source code files:
`#import <ScanbotSDK/ScanbotSDK.h>`

or

`@import ScanbotSDK;`

Step-by-step framework installation guide

Step 1 Copy the folder containing the downloaded Framework into your apps project folder Copy the folder containing the downloaded Framework into your app's project folder.

Step 2 Open your app project in Xcode Open your app project in Xcode.

Step 3 Drag the framework into your project. Navigate into the ScanbotSDK folder and drag ScanbotSDK.framework into your project's 'Frameworks, Libraries and Embedded Content' section.

Step 4 Add a runscript build phase Add a runscript build phase to strip out simulator architectures from the SDK.

Script code:


bash "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/ScanbotSDK.framework/strip-SBSDK-Framework.sh"

Script input file:


$(SRCROOT)/./ScanbotSDK/dSYMs/ScanbotSDK.framework.dSYM

Step 5 Install the additional data bundles if required.

Install additional data bundles if needed (Framework and XCFramework)

Step 1 Navigate to Build Phases In your Xcode project navigate to Build Phases.

Step 2 Navigate to AdditionalData folder In Finder navigate to the AdditionalData folder.

Step 3 Drag needed bundles Drag the required data bundles to the 'Copy Bundle Resources' section.

Want to scan longer than one minute?

Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?