Adding Thing-IF SDK

First, you need to integrate both Kii Cloud SDK and Thing-IF SDK.

Before integrating the SDKs, make sure that your target project supports Swift 2.3 on Xcode 8. See Supported Language for more information about the language for development.

Linking the SDKs

First, you need to link the Kii SDKs to your project. We explain how to link the SDKs with CocoaPods.

  1. Configure CocoaPods

    Make CocoaPods available. See the CocoaPods guides for configuring CocoaPods.

  2. Prepare a Podfile

    Create a file named Podfile in the directory that contains the XCode project file (the XCODEPROJ file) and put the following lines in the file.

    use_frameworks!
    
    target '__TargetName__' do
      pod 'KiiCloud', 'XX.YY.ZZ'
      pod 'ThingIFSDK', '0.13.1'
    
      post_install do |installer|
        target = installer.pods_project.targets.find { |t| t.to_s == "ThingIFSDK" }
        if (target)
          target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '2.3'
          end
        end
      end
    end
    

    Replace __TargetName__ with the project name. You can find the project name on Xcode as illustrated in the next screenshot.

    The version numbers of the SDKs need to be replaced with the ones you want to download.

    • KiiCloud

      You can check the latest version number by clicking the "Download" link in the developer portal. Replace the XX.YY.ZZ with this version number.

    • ThingIFSDK

      Specify a version number that is lower than 1.0.0 for the Thing-IF SDK. The latest version is 0.13.1. You cannot specify Version 1.0.0 or later because Version 1.0.0 or later is designed for specific solutions and its specification is out of the scope of this documentation. If you directly reference the source code, specify a version number that is lower than 1.0.0 with the tagging feature of GitHub as below.

      https://github.com/KiiPlatform/thing-if-iOSSDK/tree/v0.13.1

    The latter part of the Podfile sets the language for using the Thing-IF SDK to Swift 2.3.

  3. Download the Kii SDKs

    Open Terminal and move to your project directory.

    In order to download the Kii SDKs and make them referenceable from your project, execute the following command. This command also configures the frameworks that the Kii SDKs use internally.

    $ pod install
    

    This command creates a workspace file (an XCWORKSPACE file). This file contains information that defines the relation between the project and the SDKs.

  4. Reopen the workspace

    Close the project and reopen the workspace in Xcode. To do so, choose "File" > "Open", and select the directory that includes the workspace file or select the workspace file itself and click "Open".

    The SDKs are not correctly referenced by the project if you open the project file. Be careful when you open the workspace file, because the welcome window of Xcode displays a project file that was most recently opened.

Other building methods

As described in the README file in theThing-IF SDK's GitHub, you can build the SDK with Carthage or manually. If you are to build the SDK by yourself, you need to be careful about the following points:

  • You need to install the development certificate for signing the runtime modules in your PC before building the Thing-IF SDK. If you change the certificate in the push notification settings, you might need to rebuild with Carthage.

  • To integrate the Thing-IF SDK you built into the Xcode project, specify the SDK in Embedded Binaries. The Kii Cloud SDK is to be specified in Linked Frameworks and Libraries.

  • You also need to set the dependent frameworks. See Adding the Kii Cloud SDK for the details.

Configuring your project

Configure your project in Xcode as follows:

Configure the build environment

Configure the build environment in Xcode.

First, in order to build your mobile app with Swift 2.3, set "Use Legacy Swift Language Version" to "Yes" in "Build Settings". As described in Supported Language, the Thing-IF SDK is designed to be used with Swift 2.3 by default.

Then, set "Deployment Target" to the minimum OS version that your app can run on. For the Thing-IF SDK, set the OS version to 7.1 or above.

Because of a defect in Xcode, you might encounter an error that causes Simulator to fail to access the keychain. Enable "Keychain Sharing" only if you use Simulator. The Kii Cloud SDK for iOS needs to access the keychain.

Prepare your code

Add the following lines to all the files that will use the Kii Cloud SDK and Thing-IF SDK.

import KiiSDK
import ThingIFSDK

Note: Prior to Version 2.6.0, the Kii Cloud SDK required the bridging header to work with Swift. From Version 2.6.0, it does not require the bridging header anymore.