Skip to content

Swift API

The Swift SDK exposes a small public surface. The full reference for each symbol lives on a dedicated page; this page is the index.

  • Keylight.manager(sdkKey:tenantId:productId:keyPrefix:trustedPublicKeyBase64:trialDurationDays:branding:) — the one-call factory. Decodes the public key, builds KeylightConfiguration, KeylightProvider, and LicenseManager for you. This is what 99% of consumers use.
  • KeylightConfiguration(sdkKey:tenantId:productId:keyPrefix:trialDurationDays:trustedPublicKeys:keychainServicePrefix:fileStoragePolicy:branding:storeKitProductId:maxOfflineDays:) — the long-form constructor. Reach for it when you need to customize maxOfflineDays, supply multiple keys for rotation, override the keychain service prefix, or set a storeKitProductId for the StoreKit fallback path.
SymbolPurposeReference
LicenseManager@MainActor ObservableObject driving app state. Read manager.isEntitled, manager.state, manager.currentLicenseExpiresAt, manager.currentEntitlements.Keylight.manager
KeylightProviderThe HTTP client for /activate, /validate, /deactivate. Conforms to LicenseProvider. Wraps the SDK key, retry/backoff, and Ed25519 verification.Validation & revalidation
LicensePromptViewSwiftUI view rendering the activation/deactivation/trial UI on all five Apple platforms.Paywall view
BrandingConfigApp name, purchase URL, support email, tint color used by LicensePromptView.Keylight.manager
LicenseState.trial(daysRemaining:), .licensed, .expired, .invalid.License lifecycle
KeylightErrorTyped errors from activateLicense, validateLicense, deactivateLicense.Error handling
Notification.Name.keylightLicenseDidChangePosted after every state transition.Keylight.manager
  • manager.checkOnLaunch() — call once at app start.
  • manager.refreshIfNeeded() — call from .onChange(of: scenePhase) when the app becomes .active. Debounced.
  • manager.activate(key:) — drive your own activation UI. LicensePromptView calls this for you.
  • manager.deactivate() — release the instance slot.
  • manager.hasEntitlement(_:) — check whether the current lease grants a named feature flag.
  • manager.isValidKeyFormat(_:) — cheap pre-flight format check before calling activate.
  • trialDurationDays — set on Keylight.manager(...). 0 disables the trial (paid-only app).
  • maxOfflineDays — default 15, only configurable via the long-form KeylightConfiguration constructor. Hard cap on time since last successful online check; see Offline leases.
  • keychainServicePrefix — auto-derived as <tenantId>.<productId>.keylight.dev by Keylight.manager(...). Override via the long-form constructor only if you need a stable Keychain identity across a rename.
  • trustedPublicKeys: [String: Curve25519.Signing.PublicKey] — the long-form constructor accepts a kid → key map so you can ship multiple keys side-by-side during rotation. The factory decodes a single base64 key and registers it under kid = "k1".

LicenseDO, KeychainHelper, the lease wire format internals, and the retry/backoff machinery are intentionally internal. They aren’t part of the SemVer contract and can change between minor versions.