The Rollouts Developer Hub

Welcome to the Rollouts developer hub. You'll find comprehensive guides and documentation to help you start working with Rollouts as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    


Quickstart guide for Optimizely Rollouts

Welcome to the quickstart guide for Optimizely's Swift SDK. The instructions below will help you implement Rollouts and launch your first feature flag.

This guide will help you:

  1. Install the SDK
  2. Instantiate Optimizely when your app starts
  3. Create a feature flag
  4. Roll out the feature

1. Install the SDK

The Optimizely X Swift SDK 3.1.0 is written completely in Swift and uses all of its native types and patterns.


If this doesn't look familiar, you may be looking for our Objective-C SDK.

Our Swift SDK is available for distribution through CocoaPods, Carthage, or Swift Package Manager (SPM). You can use this SDK with apps written in Swift and Objective-C.


  • Swift client applications must use Swift 5 or higher.
  • Minimum OS version supported is iOS/9.0 and tvOS/9.0.


  1. Add this line to the Podfile:
pod 'OptimizelySwiftSDK','~> 3.1.0'

  1. Run the command:
pod install

For more installation information, see the CocoaPods Getting Started Guide.


  1. Add this line to the Cartfile:
github "optimizely/swift-sdk" ~> "3.1.0"

  1. Run the command:
carthage update

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

  1. To ensure that proper bitcode-related files and dSYMs are copied when archiving your app, you must install a Carthage build script:
    a. Add a new Run Script phase in your target's Build Phase.
    b. Include this line in the script area:
    /usr/local/bin/carthage copy-frameworks
    c. Add the frameworks to the Input Files list: $(SRCROOT)/Carthage/Build/<platform>/Optimizely.framework
    d. Add the paths to the copied frameworks to the Output Files list:

For more installation information, see the Carthage GitHub repository.

Swift Package Manager (SPM)

Add the following line to the dependencies value of your Package.swift:

dependencies: [
    .package(url: "", "3.1.0"..<"3.2.0")


  • All public types start with the Optimizely prefix for clarity.
  • This release includes a wrapper for all public APIs to support Objective-C client applications. See the demo Swift app on GitHub.

2. Configure Optimizely when your application starts

In Optimizely, find your SDK key by navigating to Settings > Environments.

Click to enlarge

Click to enlarge

Instantiate the client by placing the code below in AppDelegate.m. Replace 'Your_SDK_Key' with the SDK key you found above.

// In AppDelegate.swift
import Optimizely

// Build and config OptimizelyClient
let optimizely = OptimizelyClient(sdkKey: "Your_SDK_Key")

// Instantiate the client asynchronously with a callback
optimizely.start { result in
  // Use isFeatureEnabled method to see if the feature is enabled for a given user
  let enabled = optimizely.isFeatureEnabled(featureKey:"new_feature", userId: "user123")

// In AppDelegate.m
@import Optimizely;

// Build and config OptimizelyClient
self.optimizely = [[OptimizelyClient alloc] initWithSdkKey:@"Your_SDK_Key"];
// Instantiate the client asynchronously with a callback
[self.optimizely startWithCompletion:^(NSData *data, NSError *error) {
	BOOL enabled = [self.optimizely isFeatureEnabledWithFeatureKey:@"new_feature"

For a full example, see:

3. Create a feature flag

Choose a feature in your app to turn on and off with a feature flag. For your first flag, consider starting with a link or visual element that's simple to change, show, or hide based on a boolean.

To set up your first feature flag, navigate to Features > Create New Feature.

Here's how to set it up:

Click to enlarge.

Click to enlarge.

After saving, use the boolean Is Feature Enabled function to show, hide, or change some visual part of your application. Note: you should see a value of false from this function because you haven't rolled out the feature yet. You'll turn it on in the next step.

let enabled = client.isFeatureEnabled(featureKey:"new_feature", userId: "user123")
BOOL enabled = [client isFeatureEnabledWithFeatureKey:@"new_feature"

The UserID enables you to create consistent experiences for a user across multiple visits, but you don't need it for this quickstart. Make the userID any non-null string for now.

4. Roll the feature out

In Optimizely, navigate back to Features and select your feature flag.

You'll return to this feature whenever you want to update the feature flag. For example, roll out your feature incrementally by moving the slider up by 10% per day or show it to a certain group of users. Move it to 100% for a big reveal, or 0% if issues arise in production. No code deployment necessary.

A basic way to confirm that your feature flag is working:

Show the feature to yourself

  1. Navigate to your feature.
  2. Toggle it ON and move the slider to 100% traffic. Click Save.
  3. Confirm that you see the feature.

Hide the feature from yourself

  1. Navigate back to the feature.
  2. Toggle it OFF. Click Save.
  3. Confirm that you no longer see the feature.

When you're ready, go ahead and launch your feature in production. Come back and change its configuration any time, without deploying code.

Updated 2 months ago


Quickstart guide for Optimizely Rollouts

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.