Swift SDK for Optimizely Full Stack: A/B testing and feature management for product development teams

What's New

Release 3.10.1



April 8, 2022

Bug Fixes

  • Remove sources of race conditions in ProjectConfig (#449).
  • Clean up URLSession after tasks are completed (#446).


Apache 2.0 Carthage compatible Build Status Coverage Status Platforms Podspec

This repository houses the Swift SDK for use with Optimizely Full Stack and Optimizely Rollouts for Mobile and OTT.

Optimizely Full Stack is A/B testing and feature flag management for product development teams. Experiment in any application. Make every feature on your roadmap an opportunity to learn. Learn more at https://www.optimizely.com/platform/full-stack/, or see the documentation.

Optimizely Rollouts is free feature flags for development teams. Easily roll out and roll back features in any application without code deploys. Mitigate risk for every feature on your roadmap. Learn more at https://www.optimizely.com/rollouts/, or see the documentation.

Getting Started

Using the SDK

See the Swift SDK developer documentation to learn how to set up an Optimizely project and start using the SDK.


  • iOS 10.0+ / tvOS 10.0+ / watchOS 3.0+
  • Swift 5+

Installing the SDK

Please note below that <platform> is used to represent the platform on which you are building your app. Currently, we support iOS, tvOS, and watchOS platforms.

Swift Package Manager

Add the dependency on the Optimizely Swift SDK with Swift Package Manager in Xcode

  1. File -> Swift Packages -> Add Package Dependency
  2. Enter https://github.com/optimizely/swift-sdk.
  3. Accept the default rules (Version: 'Up to Next Major').


  1. Add the following lines to the Podfile:
    pod 'OptimizelySwiftSDK', '~> 3.10.1'
  1. Run the following command:
    pod install

Further installation instructions for Cocoapods: https://guides.cocoapods.org/using/getting-started.html


  1. Add the following lines to the Cartfile:

    github "optimizely/swift-sdk" ~> 3.10.1

  2. Run the following command:

    carthage update

  3. Link the frameworks to your project. Go to your project target's Link Binary With Libraries and drag over the following from the Carthage/Build/<platform> folder:


  4. To ensure that proper bitcode-related files and dSYMs are copied when archiving your app, you will need to install a Carthage build script:

    • Add a new Run Script phase in your target's Build Phase.
    • In the script area include:
      /usr/local/bin/carthage copy-frameworks
    • Add the frameworks to the Input Files list:
    • Add the paths to the copied frameworks to the Output Files list:

Futher installation instructions for Carthage: https://github.com/Carthage/Carthage


A sample code for SDK initialization and experiments:

let optimizely = OptimizelyClient(sdkKey:"somesdkkey")

optimizely.start{ result in
    do {
        let variation = try optimizely.activate(experimentKey: "background_experiment", userId: "userId", attributes: ["doubleKey":5])
        try optimizely.track(eventKey: "sample_conversion", userId: "userId")
    } catch {




First-party code (under OptimizelySwiftSDK is copyright Optimizely, Inc. and contributors, licensed under Apache 2.0.)

Additional Code

This software incorporates code from the following open source repo:

For the SDK: MurmurHash3:https://github.com/jpedrosa/sua/blob/master/Sources/murmurhash3.swift License (Apache 2.0):https://github.com/jpedrosa/sua/blob/master/LICENSE.txt Ported to Swift4.

SwiftLint:https://github.com/realm/SwiftLint License (MIT):https://github.com/realm/SwiftLint/blob/master/LICENSE Used to enforce Swift style and conventions.


  • Swift Tools 5.0.0
View More Packages from this Author


  • None
Last updated: Wed Mar 22 2023 00:20:25 GMT-0500 (GMT-05:00)