Installation Guide

DM SDK is available as an XCFramework package downloadable through the Digimarc Barcode Manager or through package managers such as Swift Package Manager and CocoaPods.

This article walks you through how to integrate DM SDK into your project through the available package managers or the XCFramework.

DM SDK requires an API key. Follow the steps under Adding the API Key to get your API key.

Package Managers

Swift Package Manager

DM SDK through Swift Package Manager is hosted on GitHub.

Installation

  1. With your Xcode project open, click the project file in the Project Navigator.
  2. Click the project again in the Projects & Targets list.
  3. Click the Package Dependencies tab.
  4. Click + under the Packages list to add a new package.
  5. On the upper trailing side, enter https://github.com/digimarc-corp/DMSDK-Apple in the Search field.
  6. Click Add Package on the bottom right side.
  7. Review the Adding the API Key section at the end of this article.

CocoaPods

DM SDK can also be found on CocoaPods. To view the Podspec:

  1. Open CocoaPods.org.
  2. In the Search field, enter DigimarcMobileSDK.
  3. Click Podspec.

Installation

  1. Open your project’s Podfile.
  2. For your appropriate Target, add DigimarcMobileSDK to your list. For example: pod 'DigimarcMobileSDK', '~> 3.6'
  3. Run pod install to fetch DigimarcMobileSDK.
  4. Review the Adding the API Key section at the end of this article.

Downloadable XCFramework

1. Download DM SDK

Download DM SDK from the Digimarc Barcode Manager. Be sure you generate your API key at the same time. Review the Adding the API Key section at the end of this article.

Adding DM SDK to your project

Copy DMSDK.xcframework to your project by dragging it from the DM SDK folder into your Xcode project’s files.

Xcode will display a dialog confirming you want to add DM SDK to your project. Confirm that Copy items if needed is selected, and that your target is checked under Add to targets.

Obj-C only projects

If your application does not include any Swift source code, you’ll need to configure your project to include the Swift Standard Library.

In your application target, under the Build Options, set Always Embed Swift Standard Libraries to Yes.

If your deployment target has Swift built in, this option is unnecessary, and will be ignored automatically. Swift is built in starting in the following OS versions:

  • iOS 12.2
  • macOS 10.14.4
  • watchOS 5.2
  • tvOS 12.2

Adding required dependencies

Depending on your Xcode configuration, you may need to add new framework dependencies to your project. If you need to add a framework dependency, click on the Project file in Xcode and open the ‘General’ tab. Towards the bottom, select the framework you want to remove from “Linked Frameworks and Libraries” and click the ( + ) button. Select the framework from the list and click “Add”.

  • QuartzCore
  • CoreGraphics
  • AVFoundation
  • UIKit

2. Configuring Code Signing

  1. In your Project, click on the General tab and select your app’s target.
  2. Select DMSDK.xcframework from the list under the Frameworks, Libraries, and Embedded Content section.
  3. Under the Embed column, choose Embed & Sign from the dropdown menu options for DMSDK.xcframework.

Adding the API key

The DM SDK requires an API key. To get an API key:

  1. Log in to Digimarc Barcode Manager using your Digimarc credentials. If you don’t have credentials, contact Digimarc Support.
  2. Click Developer at the top.
  3. In the Mobile SDK section, click CREATE MOBILE SDK USER. Type a descriptive name for your application.
  4. Click Key beside the mobile app name to get the API key.
  5. Copy the key string and save it to your computer.

Digimarc will never ask for your API key. Don’t share your API keys with anyone you don’t trust.

You can configure DM SDK’s API key when your application launches.

In your Application Delegate, import DM SDK.

Swift
import DMSDK
Obj-C
import <DMSDK/DMSDK.h>

Then, in applicationDidFinishLaunching, configure DM SDK with your API key. Replace YOUR\_API\_KEY\_GOES\_HERE with your API key.

Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    DMSDK.LicenseManager.APIKey = "YOUR_LICENSE_KEY_GOES_HERE"
    ...
}
Obj-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
    DMSLicenseManager.APIKey = @"YOUR_LICENSE_KEY_GOES_HERE";
    ...
}

Option 2: Adding the API key to your Info.plist

An API key can be added to an application with a DMSAPIKey Info.plist entry. This option does leave the key exposed in the Info.plist and is not recommended in situations where the API key is considered senstive.

Option 3: Pass the API key directly to class initializers

Classes that require an API, such as image/audio readers and the resolver, have an initializer varient that takes an API key parameter. Using this initializer allows a developer to use multiple API keys, or have greater control over how their application manages an API key. This intiailizer will fail if the API key is invalid.

Some classes in DM SDK are not reliant on an API key, such as DMSPayload/Payload. These classes will operate without a valid API key, and do not have an API key initializer.