Feature SDK implementation
Swift
Native Apple-platform decisions with datafile polling and event dispatch.
iOS / macOSThis runtime cannot execute inside a Next.js browser process. The page shows the native, official SDK shape; use the JavaScript, React, or Next.js pages for a live decision and event round trip with the same project, flag, event, and visitor ID.
Implementation
Official docs ↗Swift Package: optimizely-swift-sdk
let client = OptimizelyClient(sdkKey: sdkKey)
client.start { _ in
let user = client.createUserContext(userId: "visitor-123")
let decision = user.decide(key: "demo_flag")
user.trackEvent(eventKey: "demo_purchase")
}