How to Add an iOS Barcode Scanner SDK

| Developers

proof of delivery in the van

Barcode scanning is a challenge underestimated by many iOS developers, going well beyond updating camera permissions and extracting data from images.

Picture this: you’re deep into the development of your Native iOS app and it’s a rollercoaster ride of late nights and endless coding sprints. Your team is focused on the priority one features but you know that eventually, the app’s barcode scanner will be put to the test by real users in real-world situations. The fate of positive or negative feedback and the size of your future bug backlog hangs in the balance.

Not all iOS barcode scanner SDKs are created equal. Whether the company wants to move away from inflexible single-purpose scanners or is starting fresh, there are two major issues that always come back to haunt developers: a subpar user experience (UX) and sluggish scanner performance.

Your barcode scanner must blend into your app seamlessly, feeling like an indispensable part of the user experience rather than a cumbersome addition. It also needs to work within the constraints of the physical world of your users, whether it’s the chaotic velocity of a busy retail environment or the rough and tumble usage of ruggedized iPhones in warehouse operations.

This blog explains the key UX and performance principles to successfully integrate an iOS barcode scanning library into your Native iOS app, including a step-by-step tutorial for the Scandit SparkScan Native iOS barcode scanner SDK.

For developers using a cross-platform framework, we also have SDKs for React Native, Flutter, .NET (.NET iOS / Android), Capacitor, Cordova, Xamarin (Xamarin iOS/Android/Forms) and Titanium.

The importance of UX in iOS barcode scanning

Integrating an iOS barcode scanner library is like trying to implement concurrency and multithreading in your app. You can get into trouble fast if you’re not careful or experienced enough, but it improves the UX dramatically once you know how to use the SDK to its advantage.

More than capturing images and events

UX can make or break any iOS application – getting the art and science of navigation, interaction, and feedback right is the difference between user success and frustration. While it may seem like open-source barcode scanning libraries – a popular choice among developers – are feasible, they present the significant challenge of having to develop your own user interface (UI).

Paid libraries, on the other hand, often include pre-built UI components that reduce your reliance on UX expertise and effort.

The following UX workflows are important to consider when deciding which iOS barcode scanner SDK is right for you.

Starting the scanning process

Imagine users navigating through complex menus or switching between the app and a different interface when scanning barcodes. This isn’t just inconvenient. The disconnected experience incurs a job performance and satisfaction hit that can impact operations.

Good UX requires a seamless transition into scanning mode from within the application. As shown in the following video, the Scandit SparkScan iOS barcode scanner API enables users to swipe or tap a collapsed floating button to activate the scanner. It then provides a large, semi-transparent button to capture barcodes.

Aiming the camera

Aiming a smartphone camera can be a difficult task in situations where the barcode is far away from the user, or when they must bend or lie down to scan packages in hard-to-reach placements. It’s also challenging when packages have multiple barcodes printed on them, as all will be in the camera’s field of view and the user needs to be able to aim at and select just one.

To help users scan effectively, features like on-screen guides, visual hints, or even augmented reality (AR) overlays help position the camera correctly.

Here are two examples of in-app features:

  • A viewfinder to help users understand that scanning is active and better position the camera
  • Restricting the scan area to help users capture barcodes in cluttered areas and improve performance on low-end devices

Implementing strong and clear feedback

Your app should provide immediate and clear feedback on the success or failure of a barcode scan. A delayed or confusing response can lead to user frustration, especially in loud environments or locations where it’s hard to see the iOS device’s screen.

Feedback mechanisms include visual and auditory cues such as these examples:

  • Drawing a symbol, like a brush overlay, at the location of the detected barcode to confirm that the app scanned the intended item.
  • Playing a sound and vibrating the device when the scanner performs a capture.

Differentiating between single scan and continuous scan

Allowing users to choose between single scans and continuous scanning modes helps tailor the user experience to situations with different numbers of items to scan or different barcode configurations.

SparkScan has two modes built into its iOS barcode scanner SDK:

  • Single scan: The user triggers the scanner for every barcode, providing greater scanning precision.
  • Continuous scan: The user triggers the scanner once and the app scans multiple barcodes without further interaction, reducing user fatigue.

Integrate your iOS barcode scanner SDK now

Add enterprise-class barcode scanning in minutes with SparkScan.

Try for Free

Ensuring your iOS barcode scanner API works under real-world conditions

A fulfillment center processing thousands of packages a day is likely not the best environment for an open-source iOS barcode scanner library that takes its time to capture barcodes. Here are some considerations to think about when selecting your scanner SDK.

1. Scan performance

In enterprise and commercial environments, you should take the following scan requirements into account:

  • Speed: A barcode scanning library that captures and processes images fast means faster business operations.
  • Accuracy: Relying on barcode scanning for inventory management, asset tracking, quality control, and similar operations requires a barcode scanning library that ensures the right items are selected, picked, and tracked.
  • Field-of-view and distance: Scanners often have to deal with barcodes on objects of various sizes, shapes, and distances from the device.
  • Handling tough barcodes: A barcode may be torn, partially obscured, wrapped in plastic, or reflect light that causes glare in the camera lens – your library should be able to handle all conditions.
  • Handling multiple barcodes: Employees may need to scan multiple barcodes at the same time or in quick succession, such as a worker in a fulfillment center having to scan a product barcode and a location barcode fast to meet shipping times.

2. Low-light environments

In many settings, lighting conditions can vary widely. Barcode scanners should perform well in low-light or even no-light situations, such as stockrooms, back-of-store areas, or nighttime delivery routes.

3. Large and varied device fleets

Enterprises often have a diverse fleet of iOS-based employee devices, with different camera specifications and processor architectures (SparkScan’s system requirements are listed here).

Your barcode scanner library must be compatible with a wide range of iOS devices, ensuring employees have a consistent user experience and avoiding the need to retrain on every new device.

The fast track to iOS barcode scanning: Using Scandit SparkScan

SparkScan, part of the Scandit Smart Data Capture Platform, makes it easy for developers to add pre-built and intuitive barcode scanner capabilities to any iOS (or Android) smartphone app.

Designed with well-researched UX principles and optimized based on the feedback of thousands of customers across a range of environments, SparkScan’s iOS barcode scanner SDK requires only a few steps to integrate its features into your app.

Its key feature is a pre-built scanning interface that floats on top of any iOS app, reducing your development time and solving many common scanning pitfalls for you. The interface is customizable for different needs – for example, options to provide audio or haptic feedback, the choice of triggering scans using a phone’s physical button, and scanning in left-handed mode.

Diagram showing Scandit’s UI/UX framework for developing React Native barcode scanning applications

The following sections explain how you can implement a customizable iOS barcode scanning interface in just a few steps.

Get started with SparkScan

The fastest way to see if SparkScan is suitable for your needs is to run one of our iOS barcode scanning examples on GitHub on your development device.

Adding the pre-built SparkScan features to your app requires these steps:

  1. Add the SparkScan SDK to your project.
  2. Create the Data Capture Context instance.
  3. Configure the SparkScan Mode.
  4. Setup the Spark Scan View.
  5. Register the listener to be informed when a new barcode is scanned.

The prerequisites for the following steps are:

  1. The latest stable version of Xcode.
  2. An iOS project with a minimum iOS deployment target of 13.0 or higher.
  3. A valid Scandit Data Capture SDK license key. You can sign up for a free test account at ssl.scandit.com.

1. Add the SparkScan SDK to your project

Before setting up SparkScan, you need to obtain a valid Scandit Data Capture SDK license key:

  1. Sign up or sign in to your Scandit account
  2. Create a project
  3. Create a license key by specifying your bundle ID

If you already have a paid subscription, reach out to support@scandit.com if you need a new license key.

The simplest way to integrate the Scandit Data Capture SDK is to use CocoaPods. Alternatively, you can use Carthage, Swift Package Manager, or manually add the dynamic framework to your project by following the steps in this guide.

To add the frameworks via CocoaPods, add the desired frameworks in your Podfile. For instance, to add ScanditBarcodeCapture API add

pod 'ScanditBarcodeCapture', '~> |shortversion|'

This will also download ScanditCaptureCore API, since ScanditBarcodeCapture API depends on it.

If you want to install a specific version, you can do so by specifying the version explicitly:

pod 'ScanditBarcodeCapture', '|version|'

A specific version is necessary when you want to install a beta version.

2. Create the Data Capture Context instance

The first step to add barcode scanner capabilities to your application is to create a new Data Capture Context. The context expects a valid Scandit Data Capture SDK license key during construction.

self.context = DataCaptureContext(licenseKey: "-- ENTER YOUR SCANDIT LICENSE KEY HERE --")

3. Configure the SparkScan mode

The SparkScan Mode is configured through SparkScanSettings, allowing you to register one or more listeners that are informed whenever a new barcode is scanned.

For this blog, we set up SparkScan for scanning EAN13 codes. Change this to the correct symbologies for your use case (for example, Code 128, Code 39…).

let settings = SparkScanSettings()
settings.set(symbology: .ean13UPCA, enabled: true)
sparkScan.apply(settings, completionHandler: nil)

Next, create a SparkScan instance with the settings initialized in the previous step:

let sparkScan = SparkScan(settings: settings)

4. Setup the SparkScan View

The SparkScan built-in user interface includes the camera preview and scanning UI elements. These guide the user through the scanning process.

The SparkScanView appearance can be customized through SparkScanViewSettings.

let viewSettings = SparkScanViewSettings()
// setup the desired appearance settings by updating the fields in the object above

By adding a SparkScanView, the scanning interface (camera preview and scanning UI elements) is added automatically to your application.

To add a SparkScan View to your view hierarchy, construct a new SparkScan view. The SparkScan view is automatically added to the provided parentView:

let sparkScanView = SparkScanView(parentView: view, context: context, sparkScan: sparkScan, settings: viewSettings)

Additionally, make sure to call SDCSparkScanView.prepareScanning and SDCSparkScanView.stopScanning in your UIViewController’s viewWillAppear and viewWillDisappear callbacks, to make sure that the start-up time is optimal and scanning is stopped when the application goes into the background.

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    sparkScanView.prepareScanning()
}

override func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated)
    sparkScanView.stopScanning()
}

5. Register the listener to be informed when a new barcode is scanned

To keep track of the scanned barcodes, implement the SDCSparkScanListener protocol and register the listener to the SparkScan mode.

// Register self as a listener to monitor the SparkScan session.
sparkScan.addListener(self)

SDCSparkScanListener.sparkScan:didScanInSession:frameData: is called when a new barcode is scanned. This result can be retrieved from the first object in the provided barcodes list: SDCSparkScanSession.newlyRecognizedBarcodes. This list only contains one barcode entry.

When a barcode is scanned, it is possible to emit a sound and visual feedback using SDCSparkScanView.emitFeedback as follows:

extension ViewController: SparkScanListener {
    func sparkScan(_ sparkScan: SparkScan,
                      didScanIn session: SparkScanSession,
                      frameData: FrameData?) {
        // Gather the recognized barcode
        let barcode = session.newlyRecognizedBarcodes.first
        // This method is invoked from a recognition internal thread.
        // Dispatch to the main thread to update the internal barcode list.
        DispatchQueue.main.async {
            // Update the internal list and the UI with the barcode retrieved above
            self.latestBarcode = barcode

            // Emit sound and vibration feedback
            self.sparkScanView.emitFeedback(SparkScanViewSuccessFeedback())

            // Handle the barcode
        }
    }
}

Testing barcode scanning performance for iOS apps

The best way to test a potential iOS barcode scanning SDK is to try it out in the real world. Whether you installed SparkScan or another barcode scanning library, here are several performance testing questions to ask yourself:

  • Is there clear guidance, feedback, and helpful hints to foster a smooth workflow rather than a confused, error-prone activity?
  • Can you scan barcodes in different orientations, such as upside down and sideways? Flip the phone upside down to see how the scanner performs.
  • Can you scan barcodes with reflections and glare?
  • Can you scan barcodes at a distance? Are you able to zoom in if needed?
  • Do you receive scanning feedback in loud environments and while wearing headphones?

You can also use our barcodes sample sheet for quick evaluation.

Get your enterprise-proven iOS barcode scanner SDK

When you prioritize UX by integrating an iOS barcode scanner that simplifies usage, minimizes errors, and scales to growing business demands, you pave the way for increased adoption and productivity. Your chosen barcode scanning solution is the bridge between the app’s success and its potential for positive business transformation.

Interested in how SparkScan turns iOS smartphones into intuitive, ergonomic scanners with minimal integration time? Sign up for our free 30-day test SDK now.