Skip to content

Getting Started

jeremyosterhoudt edited this page Dec 12, 2017 · 26 revisions

PredixSDKforiOS

The Predix SDK for iOS is the easiest way to integrate with Predix services. For a complete list of features, see the features list.

Prerequisites

This guide assumes you are comfortable using Xcode, the Swift programming language, and the Swift coding concepts. If you are not already familiar with these technologies and concepts you may want to consider reading Apple's Getting Started documentation before continuing with this guide.

Before you begin:

  • Read the README file
  • Download Xcode 9.2 or later
  • Download and install the latest version of Carthage
  • If you are behind a firewall/proxy, access GitHub from the Mac Terminal

Installing and Configuring the PredixSDKForiOS

You can install the SDK using Carthage or Downloading Binaries

Using Carthage

  1. Open Xcode and create a new project, Single View App .

    File > New > Project > iOS > Single View App

  2. If you haven’t already, install the latest version of Carthage.

  3. Create a file named cartfile in your project.

  4. Enter the following dependencies into the cartfile:

binary "https://raw.githubusercontent.com/PredixDev/PredixSDKForiOS/master/Carthage/ios.json" >= 0.8
  1. Run carthage update in terminal.
  2. PredixSDK.framework is available at ./Carthage/Build/iOS.

Downloading Binary

​ Download the latest PredixSDKForiOS framework from: https://github.com/PredixDev/PredixSDKForiOS/releases

Adding the SDK to your Project

  1. Open your application's Xcode project.

  2. Create a Frameworks group in your project.

  3. Open downloaded framework using finder (typically in ~/Downloads/PredixMobileSDK_iOS_vX.X.zip) or grab from the Carthage build.

  4. Drag the PredixSDK.framework into the Frameworks group of Xcode's Project Navigator.

  5. Navigate to project/TARGETS/target/ and select the General tab in your project.

  6. Scroll down to the Embedded Binaries section and add the PredixSDK.framework from Frameworks group.

Add SDK to Project Image

Adding the Module Map

PredixSDKForiOS internally utilizes CouchbaseLite for syncing with the backend and it is written in Objective-C. Xcode requires a module map file so that PredixSDKForiOS can use CouchbaseLite module.

Note: You must create a module.modulemap file and add it to your project. If you attempt to navigate to the ViewController.swift file and add an import for PredixSDK without adding a module.modulemap file, you will encounter the following error as soon as you build your project using the CMD + B command.

Missing required module 'CouchbaseLite'

Module Map Missing Error Image

  1. Create a folder group called CouchbaseLite .

  2. Create an "Empty" file in the CouchbaseLite group and name it module.modulemap (CouchbaseLite/module.modulemap).

  3. Add the following content to the module.modulemap file :

module CouchbaseLite {
    export *
}

The module.modulemap file should look like the following:

Module Map Project

  1. Select your project and then select the non-test target under targets.
  2. Select the Build Settings tab and search for import paths.
  3. Locate the Swift Compiler - Search Paths section and update the Import Paths value with $(SRCROOT)/$(PRODUCT_NAME) module map build settings

NOTE: If you have Show Setting Names enabled in the editor menu the Setting name of the key will be SWIFT_INCLUDE_PATH instead of Import Paths

  1. Enter CMD+B to build the project again, compiler should be able to find the missing CouchbaseLite module by now.

The following screenshot shows how the project structure looks like after you build the project:

screen shot 2017-10-24 at 11 00 57 am

Congratulations! You have successfully completed the Getting Started with the PredixSDKForiOS

Next Steps

See the example project