Skip to main content
The Swift SDK is a Swift Package Manager library for Apple platforms. It exposes three client modes over the same API surface — a remote HTTP client, a pure-local on-device store, and a synced mode that queues writes locally and replays them against a server. Swift 6 concurrency throughout. Repository: withmarfa/swift-sdk. Pin to the major version that tracks your server. Platforms: iOS 26+, iPadOS 26+, macOS 26+, watchOS 26+, tvOS 26+, visionOS 26+. On-device storage uses SwiftData — no third-party runtime dependencies.

Install

In Package.swift:
Or in Xcode: File → Add Package Dependencies → https://github.com/withmarfa/swift-sdk.git.

Three client modes

One SDK, three factories. Pick the one that matches your app:
A thin typed HTTP client. Every call hits the server.
Best for: server-first apps, scripts, CI, server-to-server integrations.
Two more factories cover common auth patterns:
  • MarfaClient.fromEnvironment() — reads MARFA_API_URL and MARFA_API_KEY. Returns nil if unset.
  • MarfaClient.fromKeychain(service:account:url:accessGroup:) — loads the API key from the system Keychain. Pair with client.saveToKeychain(service:account:accessGroup:) to persist one.

Configuration

ClientConfiguration controls retry, timeout, conflict strategy, and CDN routing:
retryPolicy on the configuration controls retry behavior for transient errors — bounded exponential backoff with jitter.

Where next

The rest of the Swift SDK surface splits across five focused pages: Authentication for OAuth 2.1 and Keychain helpers, Data access for items / edges / metadata / extensions / blobs / search, Typed models for CoreNote and custom-type codegen, Sync engine for SwiftUI reactive queries and the SSE replay loop, and Errors and testing for conflict handling, error types, and MarfaSDKTestSupport.