Skip to content

Getting Started

jeremyosterhoudt edited this page Nov 20, 2017 · 26 revisions

PredixSDKforiOS

The Predix SDK for iOS is the easiest way to integrate with Predix services.

features

For a list of all features please checkout our features list from the main documentation page

Prerequisites

This guide assumes you are familiar with 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.

Also make sure you have:

  • Read the README file.
  • Download the required software.

Create a New Project

Open XCode and create a Single View App Xcode

File > New > Project > iOS > Single View App

Install and Configure the PredixSDKForiOS

You can choose to install the SDK using Carthage or by downloading the binary from our GitHub repository.

Using Carthage

  1. If you haven’t already, install the latest version of Carthage
  2. Create a file named cartfile
  3. Enter the following dependencies into the cartfile:
binary "https://raw.githubusercontent.com/PredixDev/PredixSDKForiOS/master/Carthage/ios.json" >= 0.7
  1. Run carthage update
  2. PredixMobileSDK.framework is available at ./Carthage/Build/iOS

Downloading Binary

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

Add SDK to 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 one from the Carthage build.

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

  5. In Xcode, select project/TARGETS//General tab in your project.

  6. In Embeded Binaries section, add the Add PredixMobileSDK.framework from Frameworks group.

Add SDK to Project Image

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

  1. Navigate to the ViewController.swift file and add an import for PredixMobileSDK.
  2. As soon as you try to build the project CMD + B you will see the following error -> Missing required module 'CouchbaseLite

Module Map Missing Error Image

  1. To fix the above error, create a folder group called CouchbaseLite

  2. Next, 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 image:

Module Map Project

  1. Select the project and then select the non-test target under targets
  2. Select the Build Settings tab and search for import paths
  3. Find section for Swift Compiler - Search Paths 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. Build the project again CMD+B, 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

If you want to continue learning more about developing iOS applications on Predix visit our [How to use PredixUIKit guide](Coming Soon!)

You can download the complete project here

Related Documentation

For more information about authentication, see authentication guides and examples (Coming Soon!)

For any other features, see our main guide here (Coming Soon!)