The Optimizely Swift SDK is written completely in Swift and uses all of its native types and patterns. It available for distribution through CocoaPods, Carthage, or Swift Package Manager (SPM).
You can use this SDK with apps written in Swift and Objective-C.
If you're currently using our Objective-C SDK, here's a guide to help you migrate to our newer Swift SDK.
- Swift client applications must use Swift 5 or higher.
- Minimum OS version supported is iOS 10.0, tvOS 10.0 and watchOS 3.0.
- Add this line to the Podfile:
pod 'OptimizelySwiftSDK','~> 3.10.1'
- Run the command:
For more installation information, see the CocoaPods Getting Started Guide.
- Add this line to the Cartfile:
github "optimizely/swift-sdk" ~> "3.10.1"
- Run the command:
- 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/ folder:
- 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:
c. Add the frameworks to the Input Files list:
d. Add the paths to the copied frameworks to the Output Files list:
For more installation information, see the Carthage GitHub repository.
Add the following line to the dependencies value of your Package.swift:
dependencies: [ .package(url: "https://github.com/optimizely/swift-sdk.git", .upToNextMinor(from: “3.10.1”)) ]
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.
- All public types start with the
Optimizelyprefix for clarity.
- This release includes a wrapper for all public APIs to support Objective-C client applications. See the demo Swift app on GitHub.
Updated 6 days ago