Swift
macOS and iOS. A Swift Package wrapping an xcframework of the Rust client, generated with UniFFI. The calls are the same as every other head.
Builds from the repository; there is no hosted binary framework yet. The
handle is Tenant in Swift, because the module is itself
Tacenta; everything else is spelt as on the other heads.
Build the package
From a checkout of the tacenta repository, on a Mac:
bindings/swift/build-xcframework.sh
Then add bindings/swift as a local package dependency and
import Tacenta.
Send a message
import Tacenta
let tenant = try await Tenant.connect(apiKey: apiKey)
try await tenant.signUp(username: "alice", password: password)
let client = try await tenant.signIn(username: "alice", password: password)
if let bob = try await client.find(username: "bob") {
try await client.send(to: bob.address, message: Data("hello".utf8))
}
for try await message in client.inbound() {
print(String(decoding: message.plaintext, as: UTF8.self))
}
No host or port: the handle fetches the server's service document and
finds the services from it. A self-hosted server is
Tenant.connect(apiKey:server:). Every call that touches the
network is async throws; inbound() is an
AsyncSequence of the messages as they arrive, and
receive() the same as batches, so a loop belongs in a task
rather than on a thread. The repository carries this sample as a runnable
command-line app under bindings/swift/examples/quickstart,
and tacenta init swift writes it with your key in place.
Keep the identity across runs
exportState returns the identity and live sessions to
persist; tenant.signInWithState resumes them. The sealed
variants authenticate the state and, with a Keychain-backed
SecureStore attached, resist rollback; the
Swift README
in the repository shows a Keychain store.
Reference
The generated reference, DocC of the package, regenerated at every release from the code it documents: tacenta.com/dl/reference/swift/.