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. For typical iOS apps, the high-level Swift based iOS Client SDK is recommended, though.
The simplest way to install the Plain C SDK for iOS is through the NabtoEdgeClientApi
Cocoapod. For an intro to the Cocoapods dependency manager, visit cocoapods.org.
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 'NabtoEdgeClientApi'
end
Install
Run pod install
:
$ pod install
Analyzing dependencies
Downloading dependencies
Installing NabtoEdgeClientApi (1.0.5)
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 libraries must be manually copied to your project.
Extract the .a file from the downloaded compressed archive and put the .a file in a subdirectory of your project folder, e.g. in a lib
folder so you have the following structure:
├── Nabto\ Edge\ iOS\ Demo
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── ...
│ └── main.m
├── Nabto\ Edge\ iOS\ Demo.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ ├── ...
├── README.md
├── include
│ └── NabtoEdgeClientApi/nabto_client.h <===========
└── lib
└── NabtoEdgeClientApi/libnabto_client_static.a <===========
The next section assumes a structure similar to above.
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.
For manual installation, first setup the search path for your project:
-
select your target in the “Targets” list
-
go to “Build Settings”
-
go to the “Search Paths” section
-
edit “Header Search Paths” and add
"${PROJECT_DIR}/include
.
You don’t have to update the library search path, it will be updated automatically in the next step.
Next, add the Nabto library:
-
select your target in the “Targets” list
-
go to “General”
-
go to the “Frameworks, Libraries, and Embedded Content” section
-
click ‘+’ and then ‘Add Other…’
-
locate the Nabto library you put in the local lib directory (likely in a parent of the default dir shown)
USE THE SDK
Import the header file:
#import "NabtoEdgeClientApi/nabto_client.h"
Now you can invoke the SDK:
NSLog(@"Nabto Edge Client SDK version %s running", nabto_client_version());
You should now be able to compile, link and run your application - for both simulation and actual device targets.
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.