Skip to main content
The Confidence iOS SDK provides feature flag evaluation for iOS, iPadOS, macOS, tvOS, and watchOS applications. Flags resolve once according to the evaluation context, and values read from a local cache for fast access.

Features

  • Local caching: Flag values cached locally for instant access
  • OpenFeature compatible: Standard feature flag API through OpenFeature provider
  • Automatic apply events: Tracks flag usage
  • Managed context: Automatic visitor ID and app lifecycle context
  • Offline support: Cached values available without network

Installation

Add the package dependency to your Package.swift:
dependencies: [
    .package(url: "git@github.com:spotify/confidence-sdk-swift.git", from: "1.4.5")
]
Then add the products to your target:
.product(name: "Confidence", package: "confidence-sdk-swift"),
.product(name: "ConfidenceOpenFeature", package: "confidence-sdk-swift"),

Quickstart

The SDK uses OpenFeature for flag evaluation.
import Confidence
import ConfidenceProvider
import OpenFeature

// Initialize Confidence
let confidence = Confidence.Builder(clientSecret: "your-client-secret", loggerLevel: .NONE)
    .build()

// Create OpenFeature provider with initial context
let provider = ConfidenceFeatureProvider(confidence: confidence)
let ctx = ImmutableContext(
    targetingKey: "user-123",
    structure: ImmutableStructure()
)

// Register with OpenFeature
await OpenFeatureAPI.shared.setProviderAndWait(provider: provider, initialContext: ctx)

// Get client and evaluate a flag
let client = OpenFeatureAPI.shared.getClient()
let value = client.getBooleanValue(key: "my-flag.my-boolean", defaultValue: false)
print("Flag value: \(value)")

Resources