Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback
Hey! These docs are for version 2.0, which is no longer officially supported. Click here for the latest version, 3.0!

Follow the installation instructions below for your platform and language.

## C#

The C# SDK is distributed through [NuGet](🔗). To install, run the command `Install-Package Optimizely.SDK` in the <a href="" target="_blank">Package Manager Console</a>.

The full source code is at <>.

## Java

The Java SDK is distributed through Bintray. The `core-api` and `httpclient` Bintray packages are [optimizely-sdk-core-api](🔗) and [optimizely-sdk-httpclient](🔗), respectively. You can find repository information and also instructions on how to install the dependencies on Bintray. Gradle repository and dependency configurations are shown on the right. The SDK is compatible with Java 1.6 and above.

`core-api` requires `org.slf4j:slf4j-api:1.7.16` and a supported JSON parser. We currently integrate with these parsers (listed in their selection order priority):

  1. [Jackson](🔗)

  2. [GSON](🔗)

  3. [](🔗)

  4. [json-simple](🔗)

If more than one of these parsers are available at runtime, the `core-api` chooses one for use per the selection order priority. If none of these packages are already provided in your project's classpath, you must add one.

`core-httpclient-impl` requires `org.apache.httpcomponents:httpclient:4.5.2` and provides an asynchronous event dispatcher that is described in [Configure the event dispatcher](🔗). This library isn't required and you may provide a custom `EventHandler` implementation that uses a different networking stack.

The full source code is at <>.

## JavaScript

The JavaScript SDK can be used in browser or in Node.js environments, and is distributed through [npm](🔗). Add it to your package:

We also distribute a prebuilt UMD bundle of the SDK, which may be helpful if you're prototyping in a browser. This is immediately usable with code like this:

The full source code is available on [GitHub](🔗).

## PHP

Our PHP SDK is available through [Composer](🔗). To install, use `composer require optimizely/optimizely-sdk` or add `optimizely/optimizely-sdk` in the `require` section of your `composer.json`.

The SDK requires PHP 5.5+.

The full source code is at <>.

## Python

The Python SDK is distributed through [PyPi](🔗). To install, use `pip install optimizely-sdk` or add `optmizely-sdk` your `requirements.txt`.

The full source code is at <>.

## Ruby

The gem for the Ruby SDK is distributed through [RubyGems](🔗). To install, use `gem install optimizely-sdk` or bundler to install the gem `optimizely-sdk`.

The full source code is at <>.

## Android

The Android SDK packages are available on Jcenter:

  • [android-sdk](🔗) Includes all modules.

  • [datafile-handler](🔗) – Datafile download, caching and background services.

  • [event-handler](🔗) – Dispatches decision and track events to Optimizely.

  • [user-profile](🔗) – Makes bucketing persistent.

  • [shared](🔗) – Shared code between all modules.

The `android-sdk` module transitively depends on the `datafile-handler`, `event-handler`, `user-profile`, and `shared` modules. It also includes the latest version of gson and slf4j logger. Gradle can be used to exclude any dependency if you want to replace one with another version or implementation.

To add the `android-sdk` and all modules to your project, include this line in your app's `build.gradle` in the `dependencies` block:

To exclude the default implementation of parser and slf4j, include this code:

Access the [android-sdk](🔗) repository on Bintray to determine the latest version. Note that you should be pinning your dependency to a major or minor version of the SDK to prevent breaking changes from major version upgrades from affecting your build.

Also check out the [test-app](🔗) in the SDK repository.

The full source code is at <>.

## iOS and tvOS

Our iOS and tvOS SDKs are available for distribution through CocoaPods, Carthage, or manual installation. You can use these SDKs with apps written in Objective C and Swift.

#### Requirements

iOS 8.0+ or tvOS 9.0+


In the instructions below, `<platform>` is used to represent the platform on which you are building your app. Currently, we support iOS and tvOS platforms. You should be pinning your dependency to a major or minor of the SDK to prevent breaking changes from major version upgrades from affecting your build.

#### Cocoapods

  1. Add this line to the Podfile:


    Alternatively, if you are developing on tvOS, use:


    Make sure `use_frameworks!` is also included in the Podfile:

  2. Run the command:


For more installation information, see the [Cocoapods Getting Started Guide](🔗).

#### Carthage

  1. Add this line to the _Cartfile_:

  1. Run the command:

  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:

<pre> $(SRCROOT)/Carthage/Build/&lt;platform&gt;/OptimizelySDKCore.framework $(SRCROOT)/Carthage/Build/&lt;platform&gt;/OptimizelySDKDatafileManager.framework $(SRCROOT)/Carthage/Build/&lt;platform&gt;/OptimizelySDKEventDispatcher.framework $(SRCROOT)/Carthage/Build/&lt;platform&gt;/OptimizelySDKShared.framework $(SRCROOT)/Carthage/Build/&lt;platform&gt;/OptimizelySDKUserProfileService.framework $(SRCROOT)/Carthage/Build/&lt;platform&gt;/OptimizelySDK<platform>.framework </pre>

For more installation information, see the [Carthage GitHub repository](🔗).

### Manual installation

The universal framework can be used in an application without the need for a third-party dependency manager. The universal framework packages up all Optimizely X Mobile modules, which include:

<pre> OptimizelySDKCore OptimizelySDKShared OptimizelySDKDatafileManager OptimizelySDKEventDispatcher OptimizelySDKUserProfileService </pre>

The universal framework for iOS includes builds for these architectures:

<pre> i386 x86_64 ARMv7 ARMv7s ARM64 </pre>

The universal framework for tvOS includes build for these architectures:

<pre> x86_64 ARM64 </pre>

Bitcode is enabled for both the iOS and tvOS universal frameworks.

To install the universal framework:

  1. Download the [iOS](🔗) or [tvOS](🔗) framework.

  2. Unzip the framework, then drag the framework to your project in Xcode. Xcode should prompt you to select a target. Go to **Build Phases** and make sure that the framework is under the **Link Binary with Libraries** section.

  3. Go to the **General** tab and add the framework to the **Embedded Binaries** section. If the **Embedded Binaries** section is not visible, add the framework in the **Copy Files** section (you can add this section in **Build Settings**).

  4. The Apple store will reject your app if you have the universal framework installed as it includes simulator binaries. You must run a script to strip the extra binaries before you upload the app. To do this, go to **Build Phases** and add a **Run Script** section by clicking the `+` symbol. Copy and paste the script below, replacing the `FRAMEWORK_NAME` with the proper framework name:

To build the universal framework:

  1. Build the _OptimizelySDKiOS-Universal_ or _OptimizelySDKTVOS-Universal_ schemes.

  2. Update our third-party dependencies, which are pulled in as Git submodules, by running this command:

followed by:

After building these schemes, the frameworks are output in the _OptimizelySDKUniversal/generated-frameworks_ folder.

The full source code is at <>.