Modules
Platforms
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
ctx.shards.transfer),
the client reconnects there with the ticket the server sent, and
shard.shardId changes. transfers() reports each move. When a deploy
moves the shard itself to another machine, the client reconnects the same
way, shardId stays, and transfers() reports nothing. Set
ticketProvider to get a ticket per connection attempt, for the shard it
connects to:
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 decode into your Swift structs at the boundary; no JSON-as-
Anyvalues - Background sessions: Apple’s
URLSession.backgroundworks - 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