Skip to content

iOS & macOS SDK (SwiftPM) ​

Zero-dependency Swift SDK (Connekt & ConnektNoOp) supporting iOS 15+ and macOS 13+ over native usbmuxd USB and optional LAN WebSocket + Bonjour discovery. Ships with Apple's required PrivacyInfo.xcprivacy.

Installation ​

Add Connekt via Swift Package Manager in Xcode (File → Add Package Dependencies…) or in Package.swift:

swift
dependencies: [
    .package(url: "https://github.com/K0ST/Connekt.git", from: "0.1.0")
]

Products exported:

  • Connekt — Full runtime SDK (Debug / internal builds)
  • ConnektNoOp — Zero-overhead stub (Release builds)

Lifecycle & LAN Failover ​

swift
import Connekt

// Listeners can be registered safely BEFORE calling start()
let msgSub = Connekt.channel("commands").onMessage { msg in
    print("From \(msg.src): \(msg.text)")
}

// USB-only by default (never triggers iOS Local Network permission prompt)
Connekt.start()

// Or opt into LAN Wi-Fi hot-standby failover:
Connekt.start { config in
    config.appName = "My iOS App"
    config.enableLan = true
}

Messaging, RPC & Binary Streams ​

swift
// 1. Fire-and-forget Message (defaults to Target.pc)
Connekt.channel("telemetry").post("{\"fps\":60}")

// Multicast to specific peers or broadcast to all ("*")
try await Connekt.channel("sync").send("reload", to: Target.all)

// 2. Request / Response (bidirectional)
let reply = try await Connekt.channel("echo").request("ping", timeout: 5.0)
print(reply.text)

// Handle incoming requests from PC or other peers
let reqSub = Connekt.channel("device_info").onRequest { req in
    return Payload.of("{\"ok\":true}")
}

// 3. 0-RTT Binary Streams
let out = try await Connekt.channel("files").openStream(
    to: Target.pc,
    meta: ["filename": "capture.png", "mime": "image/png"]
)
try await out.writeFrom(fileURL: fileURL)
out.close()

// Receive inbound stream with optional early reject
let streamSub = Connekt.channel("files").onStream { stream in
    if stream.meta["mime"] == "video/mp4" {
        stream.reject("unsupported")
        return
    }
    for try await chunk in stream {
        handleBytes(chunk.bytes)
    }
}

Multi-Instance Mode ​

If you need isolated sessions instead of the Connekt singleton, instantiate ConnektClient(config:) directly. Call Connekt.stop() (or client.stop()) to cleanly tear down connections.

Released under the MIT License.