iOS Swift Package
Add Capreolus to an iOS app via Swift Package Manager and start the SDK.
Install
Add the Capreolus Swift package to your Package.swift:
Package.swift
dependencies: [
.package(url: "https://github.com/capreolus/capreolus-ios", from: "0.1.0")
],
targets: [
.target(
name: "App",
dependencies: [
.product(name: "Capreolus", package: "capreolus-ios")
]
)
]Or in Xcode: File → Add Package Dependencies and paste https://github.com/capreolus/capreolus-ios.
Initialize
Call Capreolus.start as early as possible — ideally in application(_:didFinishLaunchingWithOptions:)or your App.init:
App.swift
import Capreolus
import SwiftUI
@main
struct AcmeApp: App {
init() {
Capreolus.start(
apiKey: "pub_xxx",
apiUrl: "https://api.capreolus.app"
)
}
var body: some Scene {
WindowGroup { ContentView() }
}
}Public API
| Symbol | Purpose |
|---|---|
Capreolus.start(apiKey:apiUrl:) | Bootstraps the SDK. Safe to call once at launch. |
Capreolus.identify(userId:traits:) | Associate the current session with a user. |
Capreolus.track(_:properties:) | Emit a custom event. |
Capreolus.flush() | Force-send the queued events buffer. |
Capreolus.reset() | Clear the cached user identity (call on logout). |
Privacy
The SDK does not collect IDFA. It generates a per-install anonymous id stored in the keychain and resets it on uninstall. For iOS 14.5+ you do not need to add the App Tracking Transparency prompt unless you also use a third-party ads SDK.
We publish a
PrivacyInfo.xcprivacymanifest with the package so Apple's Privacy Nutrition Labels are pre-filled for you.