SDKsSwift

Swift SDK

MembberSwift is a Swift package for iOS 16+ and macOS 13+, built on Apple's swift-openapi-generator. Every operation is an async/await method with idiomatic Swift names, generated from the platform contract.

Install

Honest status

Public Swift Package Manager distribution is planned. Today the package ships inside the Membber iOS workspace as a local SPM package, and we provide it directly to teams building with us: get in touch. Once public, it installs like any SPM dependency; the API on this page is the same either way.

  • Swift 6 toolchain, platforms iOS 16+ and macOS 13+.
  • Types and client are generated at build time by the swift-openapi-generator plugin from the bundled contract, so the package always matches the spec version it ships with.
  • Transport is URLSession; auth is a middleware that attaches your Bearer token from the tokenProvider closure on every request.

Quickstart

Auth, first call, typed result
import MembberSwift

let client = MembberClient(
    serverURL: MembberClient.productionServerURL,
    tokenProvider: { session.accessToken }
)

// A typed, authenticated read. .ok.body.json throws if the
// response is anything other than 200.
let state = try await client.api.getLoyaltyState(
    query: .init(customerId: "<customer-id>")
).ok.body.json

Handling errors

Switching over the response
let response = try await client.api.createOrder(
    body: .json(.init(/* ... */))
)

switch response {
case .ok(let ok):
    let order = try ok.body.json
    // success
case .undocumented(let status, let payload):
    // The unified error envelope arrives here with its status code.
    // Decode { error: { code, message, requestId } } from payload.
    print("request failed with status \(status)")
default:
    break
}

The generated output is an enum per operation: use the .ok shorthand when you only care about success, or switch over the cases to handle the error envelope deliberately. The idempotency and rate limit conventions apply unchanged.

Per-operation examples

Every operation in the API reference includes a generated Swift example: pick the Swift tab once and the whole reference shows Swift.

WhatsApp
Book a Call
Start Free