Plain C SDK for iOS

If you need low-level access to the full Nabto Edge Client SDK, you can use the general Plain C SDK built for iOS. The simplest way to install the Plain C SDK for iOS is through the NabtoEdgeClientApiFW Cocoapod. For an intro to the Cocoapods dependency manager, visit cocoapods.org.

For typical iOS apps, the high-level Swift based iOS Client SDK is highly recommended over the low-level, plain C based SDK. It is much simpler to use from both Swift and Objective C based apps.

COCOAPOD BASED INSTALLATION

Podfile

Reference the SDK from a Podfile in the root directory of your project:

platform :ios, '12.0'

target 'NabtoEdgeObjcCDemo' do
  pod 'NabtoEdgeClientApiFW'
end

Install

Run pod install:

$ pod install
Analyzing dependencies
Downloading dependencies
Installing NabtoEdgeClientApiFW (5.12.1)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod 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

The low level plain C-based SDK can be manually downloaded and made available for your build process: Download zip file.

The downloaded XCFramework bundle must be manually added to your project, see below.

Manually configure XCode project

Note that this step is only relevant if manually installing, if using Cocoapods, all XCode configuration is done automatically by the Cocoapods tool.

To add the Nabto library to your Xcode project:

  1. unzip the downloaded bundle in your project directory, e.g. in the root dir

  2. select your target in the “Targets” list

  3. go to “General”

  4. go to the “Frameworks, Libraries, and Embedded Content” section

  5. click ‘+’ and then ‘Add Other…’

  6. locate the NabtoEdgeClientApiFW.xcframework bundle you extracted in step 1 and add it

USE THE SDK

From Objective C, you can import NabtoEdgeClientApi after adding the NabtoEdgeClientApiFW framework bundle and then use the raw plain C API functions:

@import NabtoEdgeClientApi;

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"Nabto SDK Version %s", nabto_client_version());
}

See the API docs for more details and the examples below.

EXAMPLES

A simple example that invokes a Nabto Edge CoAP service is available in github, edge-hello-objc-cocoapods.