Skip to main content

Quick start | iOS Barcode Scanner

In this section, you'll learn how to set up the Scanbot Barcode Scanner SDK for iOS in your app, with Barcode Scanning enabled, all within 10 minutes – thanks to our Ready-to-Use UI!

Installing Scanbot SDK

Installation via Swift Package Manager

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

To get the latest version of the Scanbot SDK, please always refer to the SDK's changelog.

You can also install Scanbok SDK using Cocoapods or as an embedded framework

Installation guide

Add camera permission

To ensure your app is ready to use the ScanbotBarcodeScannerSDK, it's essential to request camera access by adding the NSCameraUsageDescription key to your Info.plist file. This step is necessary for the SDK to function properly, as it requires access to the device's camera for scanning barcodes.

Follow these steps to add the camera usage description:

  • Open your Info.plist file.
  • Click the + button and start typing Privacy - Camera Usage Description.
  • Provide a brief, user-friendly explanation of why your app needs camera access, such as: Please allow camera usage to scan barcodes.

For more details on requesting authorization to capture and save media, refer to the Apple documentation.

Initialize the SDK

In order to activate the license in the code use the +[Scanbot setLicense:] method of the Scanbot class. Execute this code as early as possible during your app's runtime, but at least before using any Scanbot SDK functionality, e.g. in your application class (AppDelegate).

If your license has expired, any invocation of the Scanbot Barcode SDK API will not work. You can check for license expiration during runtime by using the +[Scanbot isLicenseValid] method.

Example code for setting the license key string:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

Scanbot.setLicense(
"hiasVhl+q8EgpnDaCEjzDPgp6ex91j" +
"y6nLK60knb5DGnaMbxnx3pO7jrML5H" +
"5E6t1XGJ6tFsQm9mm+hSfVnetqEhe4" +
"VNfXzi/lFYpWT8ICQ1c7YbZbAeyPXc" +
"D/IcDaRz1vxS85aOL0tbYXynBzvkSx" +
"mMyFDaL/obrke4h+sonCbLauUA7yXX" +
"yWlT3gZujS6/a+SzhzpB+7+lCd+Y52" +
"GBvOsg+h8JfieM/oFzCUZrSazOEusU" +
"EyOewKLDiOdNqgJpAGK1hF1nQwhcr7" +
"PysYuECotHSE6NQ2vWJ6RqOz974prq" +
"EIjEhdprY62qD2pip2MbBHgKYL69DQ" +
"bFAgyNfSWNtg==\nU2NhbmJvdFNESw" +
"ppby5zY2FuYm90LmV4YW1wbGUuc2Rr" +
"LmRlbW8KMTU0NjM4NzE5OQo1MTIKMQ" +
"==\n")

return true
}

Start the Barcode Scanner and process the result

With just a few lines of code, the Scanbot Barcode Scanner Ready-To-Use UI component (SBSDKUI2BarcodeScannerViewController) can be integrated into your application's workflow. It's as simple as starting any regular iOS View Controller.

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerConfiguration()

// Present the recognizer view controller modally on this view controller.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in

// Completion handler to process the result.
// The `cancelled` parameter indicates if the cancel button was tapped.

controller.presentingViewController?.dismiss(animated: true)
}

🚀 That's it! 🚀 You have successfully integrated a full-featured barcode scanner as an RTU UI View Controller into your app.

💡 Customization: In this Quick Start guide, we use the default configuration for the scanner UI. Feel free to explore the configs and customize the UI and behavior according to your needs via the `BarcodeScannerConfiguration` class. For more details, please refer to the Ready-to-Use UI page.

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get your free Trial License

What do you think of this documentation?