Swift SDK
Installation prerequisites
| OS | Minimum Version | Minimum Build Environment |
|---|---|---|
| iOS | 14 | swift-tools-version: 5.9 |
| macOS | 12 | swift-tools-version: 5.9 |
Install the Swift SDK
To install the Dynamic Yield iOS SDK using Swift Package Manager (SPM) in Xcode, do the following:
- Open Xcode and navigate to your project.
- Go to Package Dependencies in the project settings.
- Click "+" to add a new package.
- In the search bar, insert the repository URL:
https://github.com/DynamicYield/Dynamic-Yield-Mobile-SDK-Swift. - Click Add Package.
- Select the relevant target and click Add Package to complete the installation.
You’re all set! The Dynamic Yield SDK should now be integrated into your project.
Note: The Swift SDK doesn’t support Obj-C apps.
Import the SDK
The SDK module is DyLibrary. Add the import to every file that uses the SDK:
import DyLibraryThe methods that send requests to Dynamic Yield (Choose Variations, pageviews, engagements, events, Search, and Shopping Muse) are asynchronous. Call them with await from an asynchronous context, or wrap the call in a Task:
Task {
let result = await DYSdk.shared().pageViews.reportHomePageView(pageLocation: "HomeScreen")
}Set up app permissions for network access
The permission is granted by default.
Updated 7 days ago
Did this page help you?
