Installation
Add the SDK
Swift Package Manager (Recommended)
In Xcode:
- File → Add Package Dependencies…
- Enter:
https://github.com/AttributeHQ/ios-sdk.git - Select version rule: Up to Next Major Version from
1.0.0
Or in Package.swift:
dependencies: [
.package(url: "https://github.com/AttributeHQ/ios-sdk.git", from: "1.0.0")
]Initialize the SDK
In your AppDelegate.swift:
import AttributeHQ
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let config = AttributeHQConfiguration(
apiKey: "ak_your_api_key",
appId: "your-app-uuid"
)
do {
try AttributeHQ.shared.initialize(configuration: config)
} catch {
print("AttributeHQ init error: \(error)")
}
return true
}Or in a SwiftUI app:
import SwiftUI
import AttributeHQ
@main
struct MyApp: App {
init() {
let config = AttributeHQConfiguration(
apiKey: "ak_your_api_key",
appId: "your-app-uuid"
)
try? AttributeHQ.shared.initialize(configuration: config)
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | String | — | Required. API key from dashboard |
appId | String | — | Required. App UUID from dashboard |
enableDebugLogging | Bool | false | Print debug logs to console |
batchSize | Int | 10 | Events per batch before auto-flush |
flushInterval | TimeInterval | 5 | Seconds between auto-flush |
maxQueueSize | Int | 100 | Max events in offline queue |
requestATTOnInit | Bool | true | Auto-request ATT permission on init |
attDelaySeconds | TimeInterval | 0 | Delay before ATT prompt |
Set requestATTOnInit: false if you want to show the ATT prompt at a custom time (e.g., after onboarding). Call requestATTPermission() manually when ready.
Required Frameworks
The SDK uses these frameworks (linked automatically via SPM/CocoaPods):
| Framework | Required | Purpose |
|---|---|---|
AdSupport | Weak | IDFA collection |
AppTrackingTransparency | Weak | ATT permission prompt |
StoreKit | Weak | SKAdNetwork conversion values |
AdServices | Weak | Apple Search Ads attribution |
All frameworks are weak-linked — the app works even on devices where they’re unavailable.