Install the Swift SDK
The Optimizely Feature Experimentation Swift SDK is written completely in Swift and uses its native types and patterns. It is distributed through Swift Package Manager (SPM).
You can use this SDK with apps written in Swift and Objective-C.
Requirements
- Swift client applications must use Swift 5 or higher.
- The minimum supported OS versions are iOS 15.0, tvOS 15.0, watchOS 9.0, and macOS 12.0.
Swift Package Manager (SPM)
Starting with version 6.0.0, Optimizely distributes the Swift SDK only through Swift Package Manager. CocoaPods and Carthage are not supported. The module name remains Optimizely, so existing import Optimizely statements do not change.
To add the SDK in Xcode, go to File > Add Package Dependencies, enter https://github.com/optimizely/swift-sdk, and accept the default rule (Up to Next Major Version).
To add the SDK to a Swift package, add the following line to the dependencies value in Package.swift:
dependencies: [
.package(url: "https://github.com/optimizely/swift-sdk.git", .upToNextMajor(from: "6.0.0"))
]Then add the Optimizely product to the dependencies of each target that imports the SDK:
.target(
name: "YourTarget",
dependencies: [
.product(name: "Optimizely", package: "swift-sdk")
]
)If you have a name conflict with other swift packages when you add the Optimizely swift-sdk dependency to Xcode, you can also try with its aliased repo: https://github.com/optimizely/optimizely-swift-sdk.git.
- Note 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.