iOS Client IAM Util

The iOS IAM Util is a helper component that simplifies pairing scenarios and other interaction with the IAM CoAP interface on Nabto Edge Embedded SDK devices.

The simplest way to install this and all dependencies is through the NabtoEdgeIamUtil Cocoapod. For an intro to the Cocoapods dependency manager, visit cocoapods.org.

COCOAPOD BASED INSTALLATION

Podfile

Reference the IAM Util pod from a Podfile in the root directory of your project:

platform :ios, '12.0'

target 'NabtoEdgeSwiftDemo' do
  pod 'NabtoEdgeIamUtil'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end
    end
  end
end

Note the post_install hook - this is mandatory to prevent runtime linker errors (immediate crash with dyld not being able to resolve some symbols in other pods that the Nabto pod depends on).

Install

Run pod install:

$ pod install
Analyzing dependencies
Downloading dependencies
Installing CBORCoding (1.3.2)
Installing Half (1.3.1)
Installing NabtoEdgeClientSwift (3.0.0)
Installing NabtoEdgeIamUtil (1.0.0)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 4 total pods installed.

If this is the first pod you use in your Xcode project, you must close your project file and open the generated workspace instead.

INSTALL WITHOUT COCOAPODS

It is not recommended to install by hand due to the dependencies of the iOS IAM Util, please use Cocoapods instead as described above. The source code is available in github and can be used if Cocoapods is not an option. The necessary dependencies to be installed by hand can be seen in the podfile (their dependencies must in turn also be installed).

USE THE SDK

To use the iOS IAM UTIL, add the following to your source file:

import NabtoEdgeIamUtil

Now you can invoke the IAM Util:

NabtoEdgeIamUtil.IamUtil.getDeviceDetailsAsync(connection: connection) { ec, result in
    if (ec == .OK) {
        if let details = result {
            self.appendText("Nabto Embedded SDK version: \(details.NabtoVersion)")
            self.appendText("Device app version: \(details.AppVersion ?? "(n/a)")")
            self.appendText("Device app name: \(details.AppName ?? "(n/a)")")
            self.appendText("Pairing modes available: \(details.Modes)")
        } else {
            self.appendText("getDeviceDetails returned OK with empty response (never here)")
        }
    } else {
        self.appendText("getDeviceDetails failed with status \(ec)")
    }
}