Skip to content

nabto/edge-client-swift

Repository files navigation

Nabto Edge Client SDK wrapper for iOS / Swift

High-level Swift wrapper for the Nabto Edge Client SDK. Distributed as a Swift Package; the underlying low-level C SDK is pulled in as a binary XCFramework from the nabto-client-sdk-releases repository.

Supports iOS 13+ and macOS 10.15+.

Installation

Xcode

FileAdd Package Dependencies… and enter:

https://github.com/nabto/edge-client-swift

Add the NabtoEdgeClient library product to your target.

Package.swift

dependencies: [
    .package(url: "https://github.com/nabto/edge-client-swift", from: "4.0.0")
],
targets: [
    .target(
        name: "YourTarget",
        dependencies: [
            .product(name: "NabtoEdgeClient", package: "edge-client-swift")
        ]
    )
]

For broader integration guidance, see the iOS getting started guide.

Usage

See the API intro for an overview of how to use the wrapper to invoke Nabto Edge devices.

A minimal SwiftUI example app lives in NabtoEdgeClientHello/ — see its README for build instructions. For more detailed usage of individual SDK features, the integration tests are the most complete reference.

Development of the wrapper

git clone git@github.com:nabto/edge-client-swift.git
cd edge-client-swift
swift build

Or open Package.swift directly in Xcode:

open Package.swift

Running tests

Most tests run against central Nabto-hosted test devices. A few cover mDNS discovery and require a local device — those are opt-in.

Default run

swift test

mDNS-dependent tests skip with a clear message. This is what CI runs (see .github/workflows/ci.yml).

Including the local mDNS tests

First start a local simple_mdns_device in another terminal:

git clone --recursive git@github.com:nabto/nabto-embedded-sdk.git
cd nabto-embedded-sdk
mkdir _build && cd _build
cmake -j ..
./examples/simple_mdns/simple_mdns_device pr-mdns de-mdns swift-test-subtype swift-txt-key swift-txt-val

Then run the suite with the opt-in flag:

NABTO_TEST_LOCAL_MDNS_DEVICE=1 swift test

From Xcode: open Package.swift, edit the NabtoEdgeClientTests scheme → RunArgumentsEnvironment Variables, and add NABTO_TEST_LOCAL_MDNS_DEVICE = 1. Then ProductTest (⌘U).

About

Nabto Edge Client SDK Swift wrapper

Resources

License

Stars

3 stars

Watchers

4 watching

Forks

Packages

 
 
 

Contributors