Pricing

Integration · SDK

sw

Swift

The Swift client ships via Swift Package Manager as MetapolicySDK. iOS 15+, macOS 12+, watchOS 8+, tvOS 15+. Built around async/await and Swift Concurrency. No legacy completion-handler API surface.

The contract

What flows in

  • Decide requests as async throws returning Assignment
  • Reward events emitted through a single async call
  • URLSession by default; supply your own if you have one configured

What flows out

  • Assignment + propensity from the same call
  • Errors as throws with typed cases for retry decisions

Setup

  1. 01Add Metapolicy package via Xcode → File → Add Package Dependencies
  2. 02Initialise once in your AppDelegate or App struct with the environment-scoped key
  3. 03Call await client.decide(...) at the decision site
  4. 04Emit rewards via await client.reward(...) when the outcome is observable
  5. 05SwiftUI: the @MetapolicyDecision property wrapper handles state + revalidation

iOS-side caching

Decisions are cached in an actor-isolated LRU keyed on (experiment, userId, contextHash). The cache is invalidated on scene-active transitions to ensure propensity reflects the live context after backgrounding.

Privacy: nothing is persisted to disk by default. The cache is process-memory only, so terminating the app clears all assignment state — matching the on-server source of truth.

Wire Swift in a 30-minute call.

We pair with your engineer, ship the integration live, and run the first decision on your stack.

Book the call