The Swift SDK provides two transports: an HTTP client and a WebSocket client. Both share the same querying and CRUD API; the WebSocket client additionally supports live queries.
HTTP client
SurrealHTTPClient connects over HTTP and is the simplest choice for request/response workloads.
WebSocket client
SurrealWebSocketClient connects over WebSocket and is required for live queries. It can also automatically reconnect when a connection is dropped.
Selecting a namespace and database
Once connected, select the namespace and database your queries should run against:
Configuration options
SurrealClientOptions
Common options shared by both the HTTP and WebSocket clients:
SurrealWebSocketOptions
Reconnection behaviour for the WebSocket client:
Closing the connection
Always close the client when you are done to release the underlying connection: