Swift
Add the Swift package in Xcode, start it once and name your screens in SwiftUI or UIKit.
The Swift package counts iPhone and iPad apps built with SwiftUI or UIKit. It is plain Swift with no dependencies. It needs iOS 15 and Xcode 16, or newer. Mobile apps explains how apps count.
Add the app to a site
An app counts under a site, the same way a website does.
- The app goes with a website. Open that site's settings and add the app's bundle ID under Apps, such as
com.acme.app. - An app with no website. In Add a site, pick An app only and enter the app's bundle ID.
Apps and sites covers separate iOS and Android IDs and app variants.
Install the package
In Xcode, choose File, then Add Package Dependencies, and paste the address:
https://github.com/ultanimus/ultanimus-swiftIn a Package.swift, add it to dependencies and to your target:
.package(url: "https://github.com/ultanimus/ultanimus-swift", from: "0.1.0").product(name: "Ultanimus", package: "ultanimus-swift")Start it
Call start once when the app launches, with the site ID from your site's settings. It reads the bundle ID and version from your app.
SwiftUI
import SwiftUI
import Ultanimus
@main
struct AcmeApp: App {
init() {
Ultanimus.start(site: "YOUR_SITE_ID")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}UIKit
import UIKit
import Ultanimus
@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Ultanimus.start(site: "YOUR_SITE_ID")
return true
}
}Name your screens
In SwiftUI, add screen to each screen's view.
struct Checkout: View {
var body: some View {
CheckoutForm()
.screen("Checkout")
}
}In UIKit, call Ultanimus.screen in viewDidAppear.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Ultanimus.screen("Checkout")
}Swift apps covers what counts as a view and how to name screens.
Send an event
Ultanimus.track("add_to_cart", ["sku": "lamp", "quantity": 2])Check that it works
Run the app from Xcode and move between a few screens. Each screen and event shows under Test events in the site's settings within a few seconds. Debug builds never count, so the dashboard stays empty until a release build sends its first event. Development builds explains test builds and staging.
Next steps
- Swift apps: signed-in people, what opened the app, storage and consent.
- Visitors and offline: how apps count visitors and send without a connection.
- App Store and Play privacy: what to answer on the App Store's form.