iOS SDK
The Swift SDK is the piece your app embeds. Zero runtime dependencies, iOS 15+. Target: a working integration in under 30 minutes.
Install (Swift Package Manager)
In Xcode → File → Add Package Dependencies… and point at the SDK repo, or add to
Package.swift:
.package(url: "https://github.com/myappaffiliate/myappaffiliate-ios", from: "0.1.0")Configure (once, at launch)
import MyAppAffiliate
AffiliateSDK.configure(
apiKey: "pk_live_…", // your app's SDK key
baseURL: URL(string: "https://api.myappaffiliate.com")!
)Attribute
Universal Link (add the Associated Domains capability — see Go-Live):
// SwiftUI
.onOpenURL { url in AffiliateSDK.attribute(url: url) }Manual code (reliable everywhere — a creator's "LUMI"):
AffiliateSDK.applyCode("LUMI")Identify the user
Use the same id you pass to RevenueCat (Purchases.shared.logIn(...)):
AffiliateSDK.identify(userId: yourUserId)Pass the affiliate into RevenueCat
Set this subscriber attribute before the purchase — it's what links subscription revenue back to the creator:
import RevenueCat
if let affiliateId = AffiliateSDK.attributedAffiliateId() {
Purchases.shared.attribution.setAttributes(["affiliate_id": affiliateId])
}API
| Call | Purpose |
|---|---|
AffiliateSDK.configure(apiKey:baseURL:) | Initialize once at launch |
AffiliateSDK.attribute(url:) | Record attribution from a Universal Link |
AffiliateSDK.applyCode(_:) | Manual-code attribution fallback |
AffiliateSDK.identify(userId:) | Bind your user id to the attribution |
AffiliateSDK.attributedAffiliateId() | The attributed affiliate id (or nil) |
Privacy
No IDFA, no fingerprinting, no cross-app tracking. The SDK stores only a generated device id (Keychain) and the attributed affiliate id. Attribution is first-party and deterministic.