Files
quicproquo/sdks/swift/README.md
Christian Nennemann 2e081ead8e chore: rename quicproquo → quicprochat in docs, Docker, CI, and packaging
Rename all project references from quicproquo/qpq to quicprochat/qpc
across documentation, Docker configuration, CI workflows, packaging
scripts, operational configs, and build tooling.

- Docker: crate paths, binary names, user/group, data dirs, env vars
- CI: workflow crate references, binary names, artifact names
- Docs: all markdown files under docs/, SDK READMEs, book.toml
- Packaging: OpenWrt Makefile, init script, UCI config (file renames)
- Scripts: justfile, dev-shell, screenshot, cross-compile, ai_team
- Operations: Prometheus config, alert rules, Grafana dashboard
- Config: .env.example (QPQ_* → QPC_*), CODEOWNERS paths
- Top-level: README, CONTRIBUTING, ROADMAP, CLAUDE.md
2026-03-21 19:14:06 +01:00

105 lines
2.3 KiB
Markdown

# QuicProChat Swift SDK
Swift wrapper over `libquicprochat_ffi` for iOS and macOS.
## Prerequisites
- Xcode 15+ / Swift 5.9+
- iOS 15+ or macOS 13+
- `libquicprochat_ffi` built for the target architecture
## Building the Native Library
```sh
# iOS (device)
cargo build --release -p quicprochat-ffi --target aarch64-apple-ios
# iOS Simulator (Apple Silicon)
cargo build --release -p quicprochat-ffi --target aarch64-apple-ios-sim
# macOS
cargo build --release -p quicprochat-ffi --target aarch64-apple-darwin
```
## Installation
### Swift Package Manager
Add to your `Package.swift`:
```swift
dependencies: [
.package(path: "sdks/swift"),
]
```
Or add the library search path to your Xcode project:
```
LIBRARY_SEARCH_PATHS = $(PROJECT_DIR)/../target/release
OTHER_LDFLAGS = -lquicprochat_ffi
```
## Usage
```swift
import QuicProChat
let client = try QpqClient(
server: "127.0.0.1:5001",
caCertPath: Bundle.main.path(forResource: "ca", ofType: "pem")!
)
try client.login(username: "alice", password: "secret")
try client.send(to: "bob", message: "hello".data(using: .utf8)!)
let messages = try client.receive(timeoutMs: 5000)
for msg in messages {
print("Received: \(msg)")
}
client.disconnect()
```
## API
| Method | Description |
|---|---|
| `QpqClient(server:caCertPath:serverName:)` | Connect to server |
| `client.login(username:password:)` | OPAQUE authentication |
| `client.send(to:message:)` | Send message by username |
| `client.receive(timeoutMs:)` | Receive pending messages |
| `client.disconnect()` | Disconnect |
| `client.isConnected` | Connection status |
## Error Handling
All errors are thrown as `QpqError`:
```swift
do {
try client.login(username: "alice", password: "wrong")
} catch QpqError.authFailed(let msg) {
print("Authentication failed: \(msg)")
} catch QpqError.connectionFailed(let msg) {
print("Connection failed: \(msg)")
}
```
## Structure
- `Sources/CQuicProChat/` -- C module map and FFI header
- `Sources/QuicProChat/QpqClient.swift` -- High-level Swift client
- `Sources/QuicProChat/QpqError.swift` -- Error types
## Cross-Compilation
For iOS devices, add the Rust target and build:
```sh
rustup target add aarch64-apple-ios
cargo build --release -p quicprochat-ffi --target aarch64-apple-ios
```
Copy the library to your Xcode project's framework search path.