How to Add an iOS Barcode Scanner SDK

| Developers

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 – read our guide on how barcode scanners work for reasons why. 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 app, including a step-by-step tutorial for Scandit SparkScan for Native iOS, a pre-built barcode scanning component that puts a minimalistic UI on top of any iOS application.

To create a native iOS barcode scanner, we’ll walk through these steps using a sample application:

  1. Add the SparkScan SDK for iOS to your project.
  2. Create a Data Capture Context instance.
  3. Change supported symbologies for your use case.
  4. Change the scanning mode.
  5. Customize the user interface.
  6. Register a listener for new barcode scans.

If you want a head start, download and run one of our iOS barcode scanning samples on your development device now.

PDF417 with DataMatrix with SparkScan

Start barcode scanning on iOS

Add enterprise-class iOS barcode scanning fast

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 video demonstrates how the SparkScan pre-built component for iOS lets users swipe or tap a collapsed floating button to activate barcode scanning. You don’t need to worry about building barcode capture logic or UI elements and workflows.

For example, a camera preview appears on screen after tapping the button, positioned directly behind the hardware camera.

These built-in UX choices make aiming and capture much easier for users rather than trying to figure them out on your own.

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.

SparkScan for iOS and other Scandit software include context-based AI scanning algorithms that reduce unwanted scans by up to 100%. Known as Smart Scan Intention, this feature uses contextual data, such as device movement and barcode characteristics, to capture the correct barcode even with imprecise aiming.

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.
Close up damaged label with SparkScan boxes on shelves

Testing the Scandit iOS SDK is easy

Integrate with just a few lines of code or use our samples

Which barcode scanner is best for iOS?

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. The scanning software’s performance is just as important as the application code you write around it.

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. To achieve these goals, select iOS barcode scanning software that captures the right data on every scan and reduces the number of unwanted scans.
  • Multi-modal data capture: Software that extracts barcode and text data from labels simultaneously means users don’t have to spend time scanning or entering them manually. Scandit’s SDK includes multi-modal data capture, making data entry up to seven times faster than scanning labels separately.
  • Field-of-view and distance: Scanners often have to deal with barcodes on objects of various sizes, shapes, and distances from the device. Deploying software that supports working ranges from tiny barcodes and electronic shelf labels (ESL) to large shipping labels means you don’t have to deal with user complaints or custom handlers.
  • Start-up time: Your barcode scanner should support a “standby mode” that minimizes the delays between scans due to the camera starting up. With Scandit software, the transition between the camera’s standby mode and on can be up to 90% faster than between off and on.
  • Handling tough barcodes: A barcode may be torn, partially obscured, wrapped in plastic, under low light, 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 such as a worker in a fulfillment center or a driver at the back of their van. Libraries built for single scans cannot handle these situations, as they don’t have the algorithms necessary to distinguish between and track multiple labels in the camera’s field-of-view. Multiple barcode scanning libraries, such as Scandit MatrixScan, can identify and track multiple barcodes without getting confused by device movement or duplicates.

The library features that matter most are covered in our blog on optimizing barcode scanning app performance. Ensuring your library includes these features gives you options for improving accuracy and speed as users scan in production.

For pre-release testing and ongoing improvement, our developer guide on how to measure barcode scanning performance provides a systematic, use-case-based testing approach to validate your app against business and user requirements.

2. Device support

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.

It must also be optimized for performance on your specific model so users don’t have to wait for scan results to complete — something not usually available with open-source packages.

We list key performance tests below to gauge how well your solution performs.

Scandit barcode scanning software is built on C/C++ to ensure core features are loaded efficiently in the background and consume minimal system resources.

3. Support for different development frameworks

If you’re working with different development platforms, ensure your barcode scanner solution supports it.

Scandit barcode scanning is available for Native Android, JavaScript, Xamarin, React Native, Flutter, .NET (iOS, Android, and MAUI), Capacitor, Cordova, and Titanium.

4. Advanced scanning features

With everyone used to sophisticated experiences and simplified workflows on iOS, they will demand no less from their barcode scanner. They may want a user interface that reduces scanning mistakes or a new approach to capture barcodes at higher volumes.

Rather than find the time to build advanced features yourself, choose an iOS barcode scanner SDK that has them built in. This way, you can get the initial release out fast and extend capabilities when users want them.

Scandit’s iOS barcode scanning library includes these features:

  • Smart Label Capture to embed multi-modal data capture into your apps to read barcodes and printed text simultaneously. This feature helps extract data up to 7 times faster for labels containing different items such as serial numbers, weights, and expiry dates.
  • Multiple barcode scanning with MatrixScan to batch scan multiple codes at once, without losing track of them as users move their devices. This reduces the time and effort needed for inventory counts, last-mile delivery, picking and packing, and other high-volume barcode scenarios.
  • Augmented reality (AR) with MatrixScan Find to help users find the right item among many items with minimal effort.

5. Support

Any business-level software package requires enterprise-level developer support. For your barcode scanner, look for:

  • iOS code samples to help you get started and familiarize yourself with the APIs.
  • Documentation that includes tutorials and API reference guides.
  • Regular updates (check the release notes) to ensure you have the latest capabilities, bug fixes, and security patches.
  • Options for technical help from developers familiar with the software and its users.

Scandit’s Enterprise-Level Success Team helps you go from trial evaluation to day-to-day barcode scanning operations with users. They can ensure barcode scanning integrates smoothly into your iOS and is optimized for your business.

6. Security and privacy

Any barcode scanner library accesses iOS device features, user data, and networking to operate. As such, you must know how it protects sensitive information in transit and at rest. At a minimum, it must comply with your organization’s security and privacy policies and with the applicable standards for your industry.

Scandit takes a security by design approach to all software, where you have complete control over data collection and processing. This means:

  • All image processing happens on the device to ensure confidentiality and high availability of scanning.
  • Any data you choose to share with Scandit is encrypted during transit and at rest.
  • Scandit is ISO 27001:2022 Certified and compliant with applicable privacy regulations that include GDPR and CCPA.

How do I create a barcode scanner for iOS?

SparkScan makes it easy for developers to add pre-built barcode scanner capabilities and a minimalistic UI that floats on top of 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 requires only a few steps to integrate its features into your app.

SparkScan’s interface consists of a small camera preview window and a large, moveable, semi-transparent trigger button that can be dragged to the most ergonomic position. When not in use, the preview window disappears and the trigger button collapses to occupy minimum space on the user’s screen.

Illustration of Scandit SparkScan’s barcode scanning UI, showing camera preview and trigger button floating on top of a retail app.

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

Get started with SparkScan for iOS

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.

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 14.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

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, or manually add the dynamic framework to your project by following the steps in this getting started guide.

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

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

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.

To import Scandit software into your source code, add the following import statements:

import ScanditCaptureCore
import ScanditBarcodeCapture

The following sections include Swift code samples. For Objective-C, refer to the SparkScan getting started guide.

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 barcodes. Change this to the symbologies for your use case (for example, Code 128, UPC).

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. Create 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 is customized through SparkScanViewSettings.

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

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)

See Workflow Options for instructions on how to change the scanning mode, set camera preview behavior, and set the scanning behavior to either single scan or continuous scan.

Additionally, make sure to call SDCSparkScanView.prepareScanning and SDCSparkScanView.stopScanning in your UIViewController’s viewWillAppear and viewWillDisappear callbacks. This ensures 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.

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

            // Handle the barcode
        }
    }
}

6. Customize the iOS UI with advanced configurations

Using advanced configurations, you can customize the SparkScan UI and UX to suit your needs and use cases. These customizations include the colors of all UI items (i.e. icons, buttons, toolbar), trigger button icon, size of the preview window, and more.

The graphic below shows three different examples of how colors, positions, and sizes can be customized to fit different iOS apps.

Now your iOS app is ready to scan!

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.

Your iOS barcode scanner SDK is more than just a technical choice

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.

Next: Dive deeper into how to make a barcode scanning app performant →