Skip to content

optimizely/swift-sdk

Repository files navigation

SWIFT SDK

Apache 2.0 Carthage compatible

This repository houses the Optimizely Mobile and OTT experimentation SDKs.

Getting Started

Using the SDK

See the Mobile developer documentation or OTT developer documentation to learn how to set up an Optimizely X project and start using the SDK.

Requirements

  • iOS 8.0+ / tvOS 9.0+

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 and tvOS platforms.

Cocoapod

  1. 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'
  1. 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.

Carthage

  1. Add the following lines to the Cartfile:
    github "optimizely/swift-sdk" "master"
  1. Run the following command:

    carthage update

  2. 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

  3. 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 

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") } 

Packages

No packages published

Contributors 25