Getting Started with Scandit SDK for iOS

This guide is split in three parts:

  1. The first part shows how you can integrate the SDK in your own app in 6 easy steps.
  2. The second part describes how to build the demo project that comes with the SDK.
  3. The last part contains some troubleshooting tips.

1. Integrating the SDK in your own app

 

1.1 Get your SDK

Create your personal account at http://account.scandit.com, get a free Development License and download the SDK (scanditsdk-devel-ios_x.x.x.zip).

 

1.2 Add the SDK to your project

The ZIP file you downloaded contains a folder named ScanditSDK. Copy this folder and add it to your XCode project.

 

1.3 Add license key file to your project

Download your personal license key file from http://account.scandit.com (via the “Download” menu) and place it in the Resources folder. Your license key file is named one of the following:

  • development_license_key.txt
  • production_license_key_free_apps.txt
  • production_license_key_paid_apps.txt

 

1.4 Add frameworks to your XCode project

The Scandit SDK needs multiple frameworks that might not be part of your XCode project yet. Add all the Frameworks that are listed in the following screenshot.


 

1.5 Prepare class to receive scanning events

First of all, change the file extension of your class’ file from .m to .mm  for XCode to know that it links to C++ classes.

To receive events from the Scandit SDK you have to implement the ScanditSDKOverlayControllerDelegate protocol. To do this, you need to perform the following steps:

  1. Edit the header file of the class that should receive these events and import a new header:
    #import "ScanditSDKOverlayController.h"
  2. Specify that your class adheres to the ScanditSDKOverlayControllerDelegate protocol. If your class is called DemoViewController and inherits from UIViewController, this looks something like this:
    @interface DemoViewController : UIViewController
        <ScanditSDKOverlayControllerDelegate> {
    }
  3. In the body of the class, add the following methods (as defined by the protocol):
    - (void)scanditSDKOverlayController:
        (ScanditSDKOverlayController *)scanditSDKOverlayController
        didScanBarcode:(NSDictionary *)barcodeResult {}
    
    - (void)scanditSDKOverlayController:
        (ScanditSDKOverlayController *)scanditSDKOverlayController
        didCancelWithStatus:(NSDictionary *)status {}
    
    - (void)scanditSDKOverlayController:
        (ScanditSDKOverlayController *)scanditSDKOverlayController
        didManualSearch:(NSString *)input {}
  4. Process the barcodeResult returned by the didScanBarcode method. The NSDictionary contains two key/value pairs:
    Key Value
    "barcode" String containing the data read from the barcode/2d code.
    "symbology" The barcode symbology. Possible values are:
    "EAN8", "EAN13", "UPC12", "UPCE", "EAN128", "CODE39", "ITF", "QR", "DATAMATRIX"

 

1.6 Add code to start the scanning process

The scanning process is started by instantiating the barcode picker (ScanditSDKBarcodePicker). The following code snippets show how to do this.

  1. Import the ScanditSDKBarcodePicker header:
    #import "ScanditSDKBarcodePicker.h"
  2. Instantiate the picker. Do not forget to replace ##AppKey## with your personal app key, which you can look up by signing in to your account at http://account.scandit.com (see “App key” link). Note that the app key is not the same as the string listed in your license key file.
    ScanditSDKBarcodePicker *picker =
        [[ScanditSDKBarcodePicker alloc] initWithAppKey:@"##AppKey##"];
  3. Specify the delegate that will receive the callback events. In this example, we assume that the delegate is the same class that also instantiated the picker:
    picker.overlayController.delegate = self;
  4. Start the scanning process:
    [picker startScanning];
  5. Show the scanner to the user. The easiest way to do so is by presenting it modally:
    [self presentModalViewController:picker animated:YES];
    [picker release];

    For alternative ways of presenting the scanner (e.g., with a UINavigationController, a UITabViewController, as a subview or in landscape mode), please refer to the demo project.

 

2. Building the demo project

The Scandit SDK (scanditsdk-devel-ios_x.x.x.zip) comes with a demo project named ScanditSDKDemo.xcodeproj. This project contains the source code of a complete app that scans barcodes. Before you can build it, you need to make a few changes to the project:

  1. Open the demo project (ScanditSDKDemo.xcodeproj) with XCode.
     
  2. Download your personal license key file from http://account.scandit.com (via the “Download” menu) and place it in the project’s Resources folder. Your license key file is named one of the following:
    • development_license_key.txt
    • production_license_key_free_apps.txt
    • production_license_key_paid_apps.txt

     

  3. In the DemoViewController.mm file, locate the following macro definition and paste your personal app key between the quotation marks. Sign in to your account at http://account.scandit.com to look up your app key (see “App key” link). Note that the app key is not the same as the string listed in your license key file.
    #define kScanditSDKAppKey @""
  4. Run the demo project.

 

3. Customizing the SDK

The Scandit SDK offers a number of customization features. Among others, the Scandit SDK offers options to:

  • Customize the scan view within your app
  • Disable barcode symbologies your app will not support
  • Add additional locales
  • Change the scan beep

For a detailed list of available API methods, see the header files included in the Scandit SDK folder.

 

4. Problems, crashes?

Please check the console output in XCode. The Scandit SDK writes log messages to the console that can help you identify problems.

If you have problems with the demo project: Did you change the project settings as described above? Did you include the license file and the app key as described above?

If your app crashes and you are using a development SDK: Does your phone have access to the internet? Your app will terminate otherwise. Note that production versions do not have this requirement and work without network access.