SDK
Swift SDK
Unified SDK for iOS and macOS — one package covers features, paywall, auth, and monitor.
Initialize
// Package.swift or Xcode → Add Package → https://github.com/onelo-tools/onelo-swift import OneloSwift // Initialize once (e.g. in your App or AppDelegate) let onelo = Onelo( publishableKey: "onelo_pk_live_YOUR_KEY", baseURL: URL(string: "https://api.onelo.tools")! ) // Sign the user in with Onelo Auth (see the Auth snippet). Every module then // acts for the signed-in user automatically — there is no identify() call to // make.
Usage
// Features — before you present gated UI (at launch AND after each sign-in),
// await the snapshot the server confirmed for THIS user. It resets on every
// identity change and is bounded: after the timeout the persisted snapshot is
// used and subscribe() fires when the confirmed one lands (OneloSwift 3.100.2+).
// Await it once, not before every read — feature() is synchronous.
await onelo.features.ready(timeout: 3)
// Build gated menus / views from the cache and rebuild them when features
// change (deploy, plan change, sign-in) — never refresh() after building them.
let unsubscribe = onelo.features.subscribe { rebuildGatedUI() }
// Read a flag off the resolved FeatureState
let isEnabled = onelo.features.feature("export-button").isEnabled // → Bool
let status = onelo.features.feature("export-button").status // → .enabled | .greyed | .hidden | .upsell
// Gating — gate on the Features SDK (the BACKEND resolves each feature against
// the user's REAL plan, works with ANY plan names) or the session entitlement:
let f = onelo.features.feature("advanced-export")
if !f.isEnabled {
// blocked → show f.badgeLabel; tap → onelo.openUpgrade(forPlan: f.requiredPlan ?? "")
}Add via Xcode → Add Package Dependencies → https://github.com/onelo-tools/onelo-swift
Your publishable key
Replace onelo_pk_live_YOUR_KEY with your key from the dashboard → SDK tab.