Getting Started with Capture SDK for iOS

Requirements

The Socket Mobile Capture SDK uses Bluetooth Classic through the External Accessory framework for the barcode scanner products and Bluetooth Low Energy (BLE) for the Contactless Reader/Writer products (Socket Mobile D600).

For applications that need to work with barcode scanners, make sure the following requirements are met:

  1. Your application needs to be registered in our whitelist before submitting your application to the Apple Store. It will not pass the Apple Store review if this is not done.

  2. Your application must have the string com.socketmobile.chs in the Supported External Protocol setting.
    ExternalAccessory

  3. Your application’s Info.plist MUST have the NSBluetoothAlwaysUsageDescription key with a string value explaining to the user how the app uses this data. This is an iOS/Apple requirement for applications that use the CoreBluetooth framework. Without it, your application will crash with a message in the Xcode console explaining that you must add the description key. Additionally, if your application has a deployment target earlier than iOS 13.0, you will need to add NSBluetoothPeripheralUsageDescription along with the NSBluetoothAlwaysUsageDescription. More information can be found here in the official Apple Documentation

  4. Your application will need a SocketMobile AppKey. Follow the link to create an AppKey. AppKeys can be generated online and at no additional cost beyond the nominal registration fee. The AppKey is validated by the SDK library on the device, no internet connection is required. Note: You don’t need to create your own AppKey to compile and run the sample apps.

  5. The scanner needs to be paired with your devices in Application Mode. This can be done using Socket Mobile Companion app (recommended), which can be downloaded from the App Store . To pair your scanner in Application Mode without using Companion app, follow the instructions at: Configure and Pair Socket Mobile Devices in Application Mode for iOS.

  6. Try a sample app. Depending on your choice of language, you can try either the Single Entry in Swift or Single Entry in Objective C.

SDK Installation

The Capture SDK is released as a CocoaPods package.

Minimum Deployment Requirement
iOS 10.0 (as of May 2021)

The SDK for iOS supports both Swift and Objective C:

  • SKTCapture for Swift

  • SKTCaptureObjC for Objective C

Generating a Podfile

If your project already uses cocoapods, you make skip the following steps and move to the “Adding Capture SDK to Podfile” section:

  • Open a terminal window and navigate to the directory of your project

  • Run this command in the terminal: pod init

  • This will generate a new file called Podfile. Open this file by typing open Podfile in your terminal. (Or simply open from the Finder window)

Adding Capture SDK to Podfile

For Swift, add this line to your Podfile:

  • pod 'SKTCapture', '~> 1.3'

The content of the file should look like this:

platform :ios, '10.0'
target 'MyApp'
  pod 'SKTCapture', '~> 1.3'

Note

The use_frameworks! is no longer necessary as of CocoaPods version 1.5.0 and should be removed. Otherwise, multiple “double symbols” link warnings will be displayed when you run your application in Debug mode.

For Objective C the same applies, just the pod name changes: - pod 'SKTCaptureObjC', '~> 1.3'

platform :ios, '10.0'
target 'MyApp'
  pod 'SKTCaptureObjC', '~> 1.3'

Installing the Capture SDK

Once you have added the pod name to your Podfile, you will need to install the SDK.

  • Save your changes/additions to the Podfile. You can safely close it now.

  • Go back to your terminal window and run this command: pod install

  • This will install the SDK within your project.

  • Once this completes, a new file will be generated called: {Name_Of_Your_Project}.xcworkspace

  • If you had the .xcodeproj open during this time, please close it and open this newly created .xcworkspace instead.

Opening the XCWorkspace file

Once you have finish

Using Capture SDK

The easiest way to use the Capture SDK in your application is to use Capture Helper, which is released in source code form as part of the Capture CocoaPods. Please refer to Capture Helper for Objective C or Capture Helper for Swift.