u/mkvisher

SwiftONVIF — Async/await ONVIF client for discovering and controlling IP cameras
▲ 12 r/swift

SwiftONVIF — Async/await ONVIF client for discovering and controlling IP cameras

Hey everyone,

ONVIF is the protocol that IP cameras use to talk to each other — discovery, authentication, streaming, PTZ control. There are solid libraries for Go, Python, Node, and Rust. For Swift, the best option has 97 stars, covers a handful of operations, and depends on a closed-source binary SOAP engine.

So I built one from scratch.

**SwiftONVIF** is a pure Swift ONVIF client library. async/await, Sendable, SPM-compatible, MIT licensed. The only dependency is XMLCoder for SOAP marshalling. Authentication uses CryptoKit — no OpenSSL.

What you get in v0.1.0:

- **WS-Discovery** — find cameras on your LAN via UDP multicast, automatically

- **Authentication** — HTTP Digest (what most cameras actually use) plus WS-Security UsernameToken

- **Device Service** — manufacturer, model, firmware, serial, capabilities, service discovery, clock sync

- **ONVIFCamera** — high-level entry point that wraps everything and auto-discovers supported services

```swift

let discovery = ONVIFDiscovery()

let cameras = try await discovery.probe(timeout: .seconds(5))

let camera = ONVIFCamera(

host: "192.168.1.100",

credential: ONVIFCredential(username: "admin", password: "pass")

)

let info = try await camera.device.getDeviceInformation()

print("\(info.manufacturer) \(info.model)")

```

Tested against a real AXIS Q6358-LE (ARTPEC-9, firmware 12.7.61). Both discovery and direct connection work. Media profiles, RTSP stream URIs, PTZ control, and imaging settings are coming in the next few releases.

https://github.com/oneshot2001/swift-onvif

If you have an ONVIF camera sitting on your desk or mounted on your wall and want to try it, camera compatibility reports are the single most helpful contribution right now. Feedback, issues, and PRs all welcome.

u/mkvisher — 6 hours ago