Swift SDK

Installation prerequisites

OSMinimum VersionMinimum Build Environment
iOS14swift-tools-version: 5.9
macOS12swift-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:

  1. Open Xcode and navigate to your project.
  2. Go to Package Dependencies in the project settings.
  3. Click "+" to add a new package.
  4. In the search bar, insert the repository URL: https://github.com/DynamicYield/Dynamic-Yield-Mobile-SDK-Swift.
  5. Click Add Package.
  6. 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 DyLibrary

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


Did this page help you?