Swift SDK: Swift Package wrapping libquicproquo_ffi with QpqClient class (connect, login, send, receive, disconnect) for iOS 15+ / macOS 13+. Kotlin SDK: JNI bridge to libquicproquo_ffi with QpqClient class for Android (aarch64, armv7) and JVM, Gradle build configuration. Adds RegisterPushToken RPC (method ID 710) to device.proto for APNs/FCM/WebPush device push token registration.
2.3 KiB
2.3 KiB
QuicProQuo Swift SDK
Swift wrapper over libquicproquo_ffi for iOS and macOS.
Prerequisites
- Xcode 15+ / Swift 5.9+
- iOS 15+ or macOS 13+
libquicproquo_ffibuilt for the target architecture
Building the Native Library
# iOS (device)
cargo build --release -p quicproquo-ffi --target aarch64-apple-ios
# iOS Simulator (Apple Silicon)
cargo build --release -p quicproquo-ffi --target aarch64-apple-ios-sim
# macOS
cargo build --release -p quicproquo-ffi --target aarch64-apple-darwin
Installation
Swift Package Manager
Add to your Package.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 = -lquicproquo_ffi
Usage
import QuicProQuo
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:
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/CQuicProQuo/-- C module map and FFI headerSources/QuicProQuo/QpqClient.swift-- High-level Swift clientSources/QuicProQuo/QpqError.swift-- Error types
Cross-Compilation
For iOS devices, add the Rust target and build:
rustup target add aarch64-apple-ios
cargo build --release -p quicproquo-ffi --target aarch64-apple-ios
Copy the library to your Xcode project's framework search path.