diff --git a/.github/workflows/sdk-examples-smoke-test.yml b/.github/workflows/sdk-examples-smoke-test.yml index 23d75f2..c893767 100644 --- a/.github/workflows/sdk-examples-smoke-test.yml +++ b/.github/workflows/sdk-examples-smoke-test.yml @@ -60,8 +60,15 @@ jobs: import PackageDescription let p = Package( name: "smoke", + // Pilot's library requires macOS 12; the consuming + // executable must declare at least the same floor or + // SwiftPM refuses to resolve the dependency. + platforms: [.macOS(.v12)], dependencies: [.package(path: "$GITHUB_WORKSPACE")], - targets: [.executableTarget(name: "smoke", dependencies: ["Pilot"])] + // The dependency package's identity is its directory name + // ("sdk-swift"), not its manifest name ("Pilot"), so the + // product must be referenced with an explicit package:. + targets: [.executableTarget(name: "smoke", dependencies: [.product(name: "Pilot", package: "sdk-swift")])] ) PKG mkdir -p Sources/smoke diff --git a/README.md b/README.md index dbd1166..8eb313e 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,14 @@ Requires iOS 14+ or macOS 12+, Swift 5.9+. ## Quick start ```swift +import Foundation import Pilot let dataDir = FileManager.default .urls(for: .applicationSupportDirectory, in: .userDomainMask)[0] .appendingPathComponent("pilot") +// Start the embedded daemon (no separate process needed). let pilot = try Pilot.start(.init( dataDir: dataDir, socketPath: "p.sock", @@ -57,15 +59,23 @@ let pilot = try Pilot.start(.init( print("address=\(pilot.start.address) node_id=\(pilot.start.nodeID)") -try pilot.handshake(peerID: 12345, justification: "hello") -_ = try pilot.waitForTrust(peerID: 12345, timeoutMs: 30_000) -try pilot.send(to: "0:0000.0000.AAAA", port: 7777, data: Data("hi".utf8)) - -Task { - while let dg = try? pilot.receive() { - print("got \(dg.data.count) bytes from \(dg.srcAddr):\(dg.srcPort)") - } -} +// Confirm the node is up. +let health = try pilot.health() +print("status=\(health["status"] ?? "unknown")") + +// To talk to a peer, handshake first, then send once trusted: +// +// try pilot.handshake(peerID: 12345, justification: "hello") +// _ = try pilot.waitForTrust(peerID: 12345, timeoutMs: 30_000) +// try pilot.send(to: "0:0000.0000.AAAA", port: 7777, data: Data("hi".utf8)) +// +// And drain inbound datagrams on a background task: +// +// Task { +// while let dg = try? pilot.receive() { +// print("got \(dg.data.count) bytes from \(dg.srcAddr):\(dg.srcPort)") +// } +// } // On shutdown try pilot.stop()