This concludes are the preparation. Let's add Telemetry to your app! Open Xcode and navigate to the project you want to add Telemetry to.
In the menu, select File -> Swift Packages -> Add Package Dependency.... This will open the Swift Package Manager view. Add the following as package repository and click Next:
There will be one or two additional screens, but you can just click Next and Finish on them – Xcode will do the right thing of linking the package against your target. (In the unlikely case that you have multiple targets, link them each with the package's library.)
This will include the Telemetry Swift Client into your app by downloading the source code. Feel free to browse the client's source code, it's very tiny and you'll see for yourself how Telemetry is hashing user identifers before they ever reach the server. Privacy, yay!
TelemetryClient package will give provide you with a class
TelemetryManager that you'll use for all interaction with Telemetry. Before you can use that class, you'll need to initialize it at the start of your app. I strongly recommend doing so as soon as possible, as you won't be able to send Signals before the
TelemetryManager is initialized.
This is slightly different depending on wether you use SwiftUI or UIKit's
AppDelegate to manage your app's lifecycle, so let's look at these individually. Please select the one that applies: