Modules
| Module | What’s in it |
|---|---|
PylonClient | HTTP client. Auth, entities, fns, files, search, aggregate, streaming. actor-isolated, swappable transport. |
PylonSync | Sync engine, LocalStore, MutationQueue, WebSocket / SSE / poll transports, SQLite persistence, InfiniteQuery, Loro CRDT bridge. |
PylonRealtime | ShardClient<State, Input> for tick-driven multiplayer shards. |
PylonSwiftUI | PylonQuery, PylonMutation, PylonSession, PylonInfiniteQuery, PylonAggregate, PylonSearch — ObservableObject wrappers. |
Platforms
| Target | Min version |
|---|---|
| iOS | 16 |
| macOS | 13 |
| tvOS | 16 |
| watchOS | 9 |
| Linux | Swift 5.9+ (uses FoundationNetworking; needs libsqlite3-dev) |
Install
InPackage.swift:
apt-get install libsqlite3-dev for the SQLite-backed offline replica.
Quickstart
SwiftUI
Auth
Entity CRUD
Streaming functions
Sync engine
Transports
Pagination
Files
Multiplayer shards
Loro CRDTs
For collaborative text/lists/maps/trees, the SDK bridges toloro-swift (the official Swift binding for Loro):
loro-swift wraps the same Rust core as the JS loro-crdt package, so convergence is identical across platforms by construction.
Codegen
Generate typed structs from your manifest:struct Todo: Codable, Identifiable, Equatable, Hashable { ... }per entitystruct NewTodo: Encodable { ... }for create payloads (id-less variant)struct CreateTodoInput: Encodable { ... }per action input- A
PylonClientextension with typedlistTodos,createTodo,deleteTodo, etc. enum PylonEntities { static let Todo = "Todo"; static let all: [String] = [...] }
Persistence
SQLitePersistence mirrors the IndexedDB schema used by the web client:
rows(entity, row_id, data)— entity rowscursors(key, last_seq)— sync cursormutations(id, payload)— offline write queue
DispatchQueue so async callers don’t hold a sync lock across await.
Background sessions
For long-running uploads / downloads, use a backgroundURLSessionConfiguration:
Storage adapters
Bearer tokens persist viaPylonStorage. Default is UserDefaults on Apple platforms, in-memory on Linux. For Keychain-backed token storage:
Differences from the React/JS clients
- Actor isolation —
PylonClientandSyncEngineareactors, so calls into them requireawait - Codable everywhere — entities are decoded into your Swift structs at the boundary; no JSON-as-
Anyfloating around - Background sessions — Apple’s
URLSession.backgroundworks seamlessly - No bundler — Swift Package Manager handles versioning, no webpack/esbuild
- Linux-compatible — server-side Swift apps can use the same SDK
Tests
Sample app
examples/swift-todo — minimal SwiftUI iOS app consuming the examples/todo-app manifest. Sign-in, optimistic insert/delete, live updates over WebSocket.
Where to next
- Sync engine — wire format, transport details
- Loro CRDTs — collaborative text/lists
- Auth — endpoint reference