This repository houses the Optimizely Mobile and OTT experimentation SDKs.
See the Mobile developer documentation or OTT developer documentation to learn how to set up an Optimizely X project and start using the SDK.
- iOS 8.0+ / tvOS 9.0+
Please note below that <platform> is used to represent the platform on which you are building your app. Currently, we support iOS and tvOS platforms.
- Add the following lines to the Podfile:
use_frameworks!pod 'OptimizelySDK', :git => 'https://github.com/optimizely/swift-sdk.git', :branch => 'master'pod 'OptimizelySDK', :path => '~/Development/swift-sdk'
- Run the following command:
pod install
Further installation instructions for Cocoapods: https://guides.cocoapods.org/using/getting-started.html
We haven't actually published to Cocoapods yet.
- Add the following lines to the Cartfile:
github "optimizely/swift-sdk" "master"
-
Run the following command:
carthage update -
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:
OptimizelySDK.framework
-
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:
$(SRCROOT)/Carthage/Build/<platform>/OptimizelySDK.framework
- Add a new Run Script phase in your target's Build Phase.
Futher installation instructions for Carthage: https://github.com/Carthage/Carthage
let optimizely = OptimizelyManager.Builder().build() if let optimizely = optimizely?.initialize(datafile:json) { let variation = optimizely.activate(experimentKey: "background_experiment", userId: "userId", attributes: ["doubleKey":5]) let basicVariation = optimizely.track(eventKey: "sample_conversion", userId: "userId") }