p2p-swift.git
ird-p2p-swift — native Swift SDK for iOS 16+ and
macOS 13+ apps on the ird p2p service: rooms that
find each other through the app's signaling relay, WebRTC data channels with
TURN and the relay as fallback, end-to-end encryption, invite links, verified
identities, and the offline mailbox. One library product,
IrdP2P.
Use as a dependency
No registry — a Swift Package served straight from this domain:
// Package.swift
dependencies: [
.package(url: "https://ird.cod-sursa.ro/p2p-swift.git", from: "0.2.0"),
],
targets: [
.target(name: "MyApp", dependencies: [.product(name: "IrdP2P", package: "p2p-swift")]),
]
The latest release is v0.2.0
(588a219). To pin that exact commit:
.package(url: "https://ird.cod-sursa.ro/p2p-swift.git", revision: "588a219d60321b5d33f3495f76c2da0ff0262fd4")
These coordinates are filled from releases.json,
which scripts and agents can read directly (head, tag,
tag_sha per repo).
Xcode
File ▸ Add Package Dependencies…, paste
https://ird.cod-sursa.ro/p2p-swift.git, choose “Up to Next Major
Version” from 0.2.0, and add the IrdP2P product to your app
target. WebRTC arrives transitively as a binary Swift package from GitHub.
Quickstart
import IrdP2P
let app = P2PApp(host: "myapp.ap2p.ro", appSalt: "myapp/v1",
origin: "https://myapp.example") // an Origin the app's allowlist admits
let secret = RoomSecret.random() // share it in an invite link's fragment
let room = try await app.join(secret: secret)
for await event in room.events {
switch event {
case .peerReady(let peer, let via): print(peer, via) // .relayed, then .direct
case .message(let from, .json(let v)): print(from, v)
default: break
}
}
try await room.broadcast(json: ["text": "salut"])
The full guide — identity and invite links, the offline mailbox, errors,
origins for native clients — is in the repo's README.md; the
end-to-end envelope format is specified in PROTOCOL.md.
Clone
git clone https://ird.cod-sursa.ro/p2p-swift.git
browse the source in your browser →
What's inside
Sources/IrdP2PCrypto/— room derivations, sealed envelopes, identities (CryptoKit only)Sources/IrdP2PSignaling/— the service's wire contract: relay session, descriptor, TURN, mailboxSources/IrdP2P/— rooms, peers, WebRTC data channels, sealed mailbox, the public facadeExamples/RoomChat/— a SwiftUI room chat for iOS and macOSTests/— golden vectors, offline suites with fake transports, env-gated live and node-server suitesPROTOCOL.md— the SDK's end-to-end envelope specification
License
MIT.