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
Add the package
Add the Grometrics Swift package in Xcode Package Dependencies.
Package URL
1https://github.com/grometrics/grometrics-swiftConfigure 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 {5init() {6Grometrics.configure(websiteId: "YOUR_SITE_ID")7Grometrics.appOpen()8}9}
Track screens
Call screenView when a SwiftUI view appears.
CheckoutView.swift
1.onAppear {2Grometrics.screenView(name: "Checkout", screenClass: "Checkout")3}
Options / Configuration
| Option | Type | Required | Description |
|---|---|---|---|
| websiteId | string | ✓ | Your Grometrics site ID |
| appVersion | string | no | Populates app version filters |
| debug | boolean | no | Logs 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?