diff --git a/CHANGELOG.md b/CHANGELOG.md index 46ce59f..6062e50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [Unreleased] + +### Changed + +* Migrated distribution from CocoaPods to Swift Package Manager. The underlying Nabto Edge Client C SDK is now consumed as a binary `XCFramework` target pulled from [nabto-client-sdk-releases](https://github.com/nabto/nabto-client-sdk-releases) instead of via the `NabtoEdgeClientApi` pod. +* Source layout moved to the SPM convention: `Sources/NabtoEdgeClient/` and `Tests/NabtoEdgeClientTests/`. +* Example app rewritten as a SwiftUI project under `NabtoEdgeClientHello/`, consuming the wrapper as a local Swift Package. +* Tests that require a local `simple_mdns_device` are now opt-in via `NABTO_TEST_LOCAL_MDNS_DEVICE=1`; default `swift test` skips them cleanly so CI and contributors without a local device aren't blocked. +* Update underlying Nabto Edge Client SDK to 5.15.3. + +### Removed + +* CocoaPods podspec, Podfile, and `.xcworkspace`. The legacy `build.sh` / `sync.sh` pod-publishing helpers are no longer wired into any release flow. + ## [3.2.0] - 2023-12-06 ### Added diff --git a/README.md b/README.md index 41e91f5..df2d0f2 100644 --- a/README.md +++ b/README.md @@ -1,72 +1,87 @@ # Nabto Edge Client SDK wrapper for iOS / Swift -High level swift wrapper for the [Nabto Edge Client SDK](https://docs.nabto.com/developer.html). Depends on the [low-level](https://docs.nabto.com/developer/api-reference/plain-c-client-sdk/intro.html) NabtoEdgeClientApi [cocoapod](https://cocoapods.org/pods/NabtoEdgeClientApi). +High-level Swift wrapper for the [Nabto Edge Client SDK](https://docs.nabto.com/developer.html). Distributed as a Swift Package; the underlying [low-level C SDK](https://docs.nabto.com/developer/api-reference/plain-c-client-sdk/intro.html) is pulled in as a binary `XCFramework` from the [nabto-client-sdk-releases](https://github.com/nabto/nabto-client-sdk-releases) repository. + +Supports iOS 13+ and macOS 10.15+. ## Installation -Use the following Podfile to install through cocoapods: +### Xcode + +`File` → `Add Package Dependencies…` and enter: ``` -target 'NabtoEdgeClientHello' do - use_frameworks! - pod 'NabtoEdgeClientSwift' -end +https://github.com/nabto/edge-client-swift +``` + +Add the `NabtoEdgeClient` library product to your target. + +### Package.swift + +```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 more installation instructions, see the [iOS getting started guide](https://docs.nabto.com/developer/guides/get-started/ios/intro.html). +For broader integration guidance, see the [iOS getting started guide](https://docs.nabto.com/developer/guides/get-started/ios/intro.html). ## Usage -See the [API intro](https://docs.nabto.com/developer/api-reference/ios-sdk/intro.html) to learn how to use the wrapper to invoke Nabto Edge devices. - -Until a full example app is ready, take a look at the [integration tests](https://github.com/nabto/edge-client-swift/blob/master/NabtoEdgeClient/NabtoEdgeClientTests/NabtoEdgeClientTests.swift) for examples of how each SDK feature is used. +See the [API intro](https://docs.nabto.com/developer/api-reference/ios-sdk/intro.html) for an overview of how to use the wrapper to invoke Nabto Edge devices. -## Development of wrapper +A minimal SwiftUI example app lives in [`NabtoEdgeClientHello/`](NabtoEdgeClientHello/) — see its README for build instructions. For more detailed usage of individual SDK features, the [integration tests](Tests/NabtoEdgeClientTests/NabtoEdgeClientTests.swift) are the most complete reference. -To build the wrapper, retrieving dependencies through CocoaPods: +## Development of the wrapper -``` +```sh git clone git@github.com:nabto/edge-client-swift.git -cd edge-client-swift/NabtoEdgeClient -pod install -open NabtoEdgeClient.xcworkspace +cd edge-client-swift +swift build ``` -Alternatively, obtain the Nabto Edge Client SDK binary library directly from the [artifacts repo](https://github.com/nabto/nabto5-releases) instead of using CocoaPods. +Or open `Package.swift` directly in Xcode: -## Running integration tests +```sh +open Package.swift +``` + +## Running tests -Remote tests are run towards some central test devices. +Most tests run against central Nabto-hosted test devices. A few cover mDNS discovery and require a local device — those are opt-in. -To enable testing of mDNS discovery, run a local test device as follows: +### Default run +```sh +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: + +```sh git clone --recursive git@github.com:nabto/nabto-embedded-sdk.git cd nabto-embedded-sdk -mkdir _build -cd _build +mkdir _build && cd _build cmake -j .. -cd _build ./examples/simple_mdns/simple_mdns_device pr-mdns de-mdns swift-test-subtype swift-txt-key swift-txt-val ``` -Execute test from xcode or commandline: - -``` -xcodebuild test -workspace "NabtoEdgeClient/NabtoEdgeClient.xcworkspace" -scheme NabtoEdgeClientTests \ - -destination 'platform=iOS Simulator,name=iPhone 8' -``` - -## Testing the resulting pod for Swift +Then run the suite with the opt-in flag: -Add local repo: - -``` -pod repo add local-repo ~/git/local-cocoapods-repo.git +```sh +NABTO_TEST_LOCAL_MDNS_DEVICE=1 swift test ``` -Push spec to local repo: - -``` -pod repo push local-repo NabtoEdgeClientSwift.podspec -``` +From Xcode: open `Package.swift`, edit the `NabtoEdgeClientTests` scheme → `Run` → `Arguments` → `Environment Variables`, and add `NABTO_TEST_LOCAL_MDNS_DEVICE` = `1`. Then `Product` → `Test` (⌘U). diff --git a/Tests/NabtoEdgeClientTests/NabtoEdgeClientTests.swift b/Tests/NabtoEdgeClientTests/NabtoEdgeClientTests.swift index 5ae3494..97c8dff 100644 --- a/Tests/NabtoEdgeClientTests/NabtoEdgeClientTests.swift +++ b/Tests/NabtoEdgeClientTests/NabtoEdgeClientTests.swift @@ -263,10 +263,7 @@ class NabtoEdgeClientTests: NabtoEdgeClientTestBase { // ./examples/simple_mdns/simple_mdns_device pr-mdns de-mdns swift-test-subtype swift-txt-key swift-txt-val func testMdnsDiscovery() throws { -// throw XCTSkip("Needs local device for testing") - #if !targetEnvironment(simulator) - throw XCTSkip("mDNS forbidden on iOS 14.5+ physical device, awaiting apple app approval of container app") - #endif + try requireLocalMdnsDevice() let scanner = self.client.createMdnsScanner(subType: self.testDevices.mdnsSubtype) let exp = XCTestExpectation(description: "Expected to find local device for discovery, see instructions on how to run simple_mdns_device stub") let stub = TestMdnsResultReceiver(exp) @@ -284,6 +281,7 @@ class NabtoEdgeClientTests: NabtoEdgeClientTestBase { } func testReproduceMdnsCrash() throws { + try requireLocalMdnsDevice() let exp = XCTestExpectation(description: "dummy") let stub = BlockingMdnsResultReceiver(exp, self) @@ -1086,7 +1084,7 @@ class NabtoEdgeClientTests: NabtoEdgeClientTestBase { } func testGetTypeDirect() throws { - throw XCTSkip("Needs a local edge device discoverable via mDNS") + try requireLocalMdnsDevice() try self.connect(self.testDevices.localMdnsDevice) XCTAssertEqual(try self.connection.getType(), .DIRECT) } @@ -1112,6 +1110,13 @@ class NabtoEdgeClientTestBase: XCTestCase { String(UUID().uuidString.lowercased().prefix(16)) } + func requireLocalMdnsDevice() throws { + try XCTSkipUnless( + ProcessInfo.processInfo.environment["NABTO_TEST_LOCAL_MDNS_DEVICE"] == "1", + "Set NABTO_TEST_LOCAL_MDNS_DEVICE=1 and run simple_mdns_device to enable. See README." + ) + } + override func setUpWithError() throws { print(Client.versionString()) setbuf(__stdoutp, nil)