This plugin allows you to easily add Smartlook support to your applications through Analytics-Swift
To add this plugin to your project, you'll need to install the Smartlook library as an additional dependency. There are two ways to add the dependency:
- Open Xcode and go to the File menu.
- Click Add Packages.
- In the search field, enter the URL to this repo: https://github.com/smartlook/segment-swift-package
- You'll then have the option to pin to a version, or specific branch, as well as which project in your workspace to add it to.
- Once you've made your selections, click the Add Package button.
Add the following to your Package.swift
file under the dependencies
section:
.package(
name: "SmartlookSegmentPlugin",
url: "https://github.com/smartlook/segment-swift-package",
from: "1.0"
),
Note the Smartlook library itself will be installed as an additional dependency.
- Open the file where you setup and configure the Analytics-Swift library.
- Import the plugin by adding this line at the top of the file:
import Segment
import SmartlookSegmentPlugin
- Beneath your Analytics-Swift library setup, add the plugin to the Analytics timeline by invoking
analytics.add(plugin: ...)
, like this:
let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KEY>")
.flushAt(1)
.trackApplicationLifecycleEvents(true))
analytics.add(plugin: SmartlookSegmentPlugin(projectKey: "<YOUR SMARTLOOK PROJECT KEY >"))
Once you've added the plugin, your events will begin streaming to Smartlook.