iOS: Get Started

View as Markdown
Last updated November 15, 2026

Installation

Before You Begin

Before you begin implementing the Lytics SDK for iOS, please make sure you have the following:

  • Access to a Lytics account capable of collecting streaming data.
  • The latest version of Xcode (v14.0+ or higher)
  • An iOS app that you can use to implement the Lytics SDK for iOS

Step 1. Add the Lytics SDK & Dependencies:

You can add the Lytics SDK to an Xcode project as a package dependency.

  1. From the File menu, select Add Packages...
  2. Enter https://github.com/lytics/ios-sdk into the package repository URL text field and click Add Package
  3. Add the Lytics package product to your application target

Step 2. Configure the SDK

A variety of top-level configuration options are available to ensure the SDK can be tailored to the needs of your particular application. To get started, however, we need only add your valid Lytics API token to the Lytics.shared.start initialization call as outlined below:

Lytics.shared.start(apiToken: "YOUR-VALID-LYTICS-API-TOKEN")

Step 3. Identifying a User

Once we have initialized the SDK, it is a best practice to identify the user anywhere formally they provide additional strong identifiers, such as a username or email, upon login, for example. This ensures your profiles have the highest potential for properly unifying across your various data sources.

Do note, this step is optional. By default, the Lytics SDK will create an anonymous identifier for all users and leverage that to merge with disparate sources as we do with our traditional web-based JavaScript SDK.

Swift

Lytics.shared.identify(
  identifiers: AnyCodable([
      "email" : "kevin@homealone.com",
  ])
)

Step 4. Tracking Activity

Once the user has been identified (optional), we can begin tracking various activities throughout their visit. Typical activities include screen views, clicks, purchases, etc. A full scope of event tracking flexibility can be found in the technical documentation section below.

Lytics.shared.track(
  name: "purchase",
  properties: AnyCodable([
    "total" : 19.99,
    "item" : "Slingshot"
  ])
)