Swift SDK
The Swift SDK is the typed client for the REST API on Apple platforms: generated API clients, Codable models, and auth through OneHorizonAPIConfiguration.customHeaders.
Read the SDK docs
Getting started
Add the package with Swift Package Manager, in Xcode or in Package.swift:
.package(url: "https://github.com/onehorizonai/swift.git", from: "1.1.0")Choose the credential boundary
Never ship a workspace API key, OAuth client secret, or registration access token in an app. A signed-in user's OAuth tokens are different: a native app can obtain them with authorization code flow and PKCE, store them in the iOS Keychain, and refresh them without a backend.
- Users sign in: create a Native iOS (public) app in Settings → Apps, follow the OAuth app guide, and store the user's access and refresh tokens in the Keychain. The maintained
Examples/NativeOAuthapp covers PKCE,ASWebAuthenticationSession, token exchange, refresh, and Simulator tests. - Anonymous features such as “Report issue”: the app sends the request to your backend; your backend uses its One Horizon API key to create the bug.
// Trusted backend only. Never inside an iOS app binary.import OneHorizonimport Foundation let config = OneHorizonAPIConfiguration.sharedconfig.customHeaders["Authorization"] = "Bearer \(ProcessInfo.processInfo.environment["ONE_API_KEY"] ?? "")" let bug = try await TasksAPI.reportBug( workspaceId: "current", report: ReportTriageItemRequest(title: "Checkout fails after applying a discount"), apiConfiguration: config) print(bug.taskId ?? "")
reportBug and submitIdea create items directly in Triage. One Horizon derives the reporter from the credential and supplies the scope, status, visibility, role, origin, and report time.
Add report context
Pass only the context your integration has:
let idea = try await TasksAPI.submitIdea( workspaceId: "current", report: ReportTriageItemRequest( title: "Let customers save multiple shipping addresses", description: "Customers want to reuse addresses during checkout.", reporterUserId: "u_...", source: "customer-portal", priority: .medium, teamIds: Set(["team_..."]), assigneeIds: Set(["u_..."]), labels: [LabelSnapshot(name: "Checkout", type: .component)] ), apiConfiguration: config)
For tasks that need explicit lifecycle, scope, kind, or routing fields, call createTask. The REST API guide covers follow-up links, documents, files, and error handling.