iOS (Swift)

Install the iOS SDK and send app lifecycle events.

Last updated June 3, 2026

Install the iOS SDK, configure the site ID, and send app_open, screen_view, and app_background events.

Prerequisites

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

Steps

1

Add the package

Add the Grometrics Swift package in Xcode Package Dependencies.

Package URL

1https://github.com/grometrics/grometrics-swift
2

Configure on launch

Start the tracker in App or AppDelegate.

Replace YOUR_SITE_ID with your site ID from Settings > Tracking.

App.swift

1import Grometrics23@main4struct MyApp: App {5  init() {6    Grometrics.configure(websiteId: "YOUR_SITE_ID")7    Grometrics.appOpen()8  }9}
3

Track screens

Call screenView when a SwiftUI view appears.

CheckoutView.swift

1.onAppear {2  Grometrics.screenView(name: "Checkout", screenClass: "Checkout")3}

Options / Configuration

OptionTypeRequiredDescription
websiteIdstringYour Grometrics site ID
appVersionstringnoPopulates app version filters
debugbooleannoLogs setup events in development

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?