iOS (Swift)

Install the iOS SDK and track app opens and screens.

Last updated June 3, 2026

Install the iOS SDK, configure the site ID, and send app_open and screen_view events. Lifecycle events can be sent explicitly with trackEvent when your app observes them. See what the SDK can do →.

Prerequisites

  • A Grometrics site ID from Settings > Tracking
  • Access to the mobile app code
  • A debug build or simulator for verification

Steps

1

Add version 1.1.1

Add the Grometrics Swift package in Xcode Package Dependencies and select the 1.1.1 tag.

Package URL

1https://github.com/codelinglabs/grometrics-ios.git
2

Create and start the tracker

Keep one tracker instance for the app lifecycle.

Replace YOUR_SITE_ID with your site ID from Settings > Tracking.

App.swift

1let grometrics = GrometricsTracker(2  configuration: .init(websiteId: "YOUR_SITE_ID")3)45await grometrics.start()
3

Identify and reset

Identify after login so anonymous and server activity merge. Reset before sign-out on a shared device.

Auth.swift

1await grometrics.identify(userId: user.id)23await grometrics.reset()4await auth.signOut()
4

Track screens

Send readable screen names from navigation changes.

CheckoutView.swift

1await grometrics.trackScreen(2  name: "Checkout",3  path: "/checkout"4)

Options / Configuration

OptionTypeRequiredDescription
websiteIdstringYour Grometrics site ID
appVersionstringnoPopulates app version filters

What happens next

Open the app in a simulator and confirm app_open and screen_view in Realtime.

Verify your setup

Verify your setup

Troubleshooting

No event appears

Confirm the site ID matches Settings > Tracking and that the latest published code is running.

Was this page helpful?