The WorkOS iOS SDK provides convenient access to AuthKit and the WorkOS API from Swift applications. It includes public-client helpers for native authentication with PKCE, async API clients, typed models and errors, automatic retries, and pagination helpers.
- Sign up for a WorkOS account.
- Create or select an application in the WorkOS Dashboard, then configure its redirect URI.
- Copy the application's client ID and follow the AuthKit documentation.
- iOS 16+ / Mac Catalyst 16+ / macOS 13+ / tvOS 16+ / watchOS 9+ / visionOS 1+
- Xcode 26+
- Swift 6.2+
In Xcode, open your project and choose File > Add Package Dependencies, then enter:
https://github.com/workos/workos-ios
Alternatively, add the package to your Package.swift:
dependencies: [
.package(url: "https://github.com/workos/workos-ios", from: "0.1.0")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "WorkOS", package: "workos-ios")
]
)
]Use PublicClient for native authentication. It requires only your application's client ID and uses PKCE, so no API key or client secret is embedded in your app.
import WorkOS
let workos = PublicClient(clientID: "client_...")
let authorization = try workos.getAuthorizationUrlWithPKCE(
redirectUri: "https://example.com/auth/callback",
provider: "authkit"
)
// Present authorization.url with ASWebAuthenticationSession. After WorkOS
// redirects back to your app, validate the returned state, then exchange the
// authorization code using the original PKCE verifier.
let authentication = try await workos.authenticateWithCode(
code: authorizationCode,
codeVerifier: authorization.codeVerifier
)Store authorization.codeVerifier securely until the callback completes, and verify that the returned state matches authorization.state before exchanging the code.
Important
Never include a WorkOS API key in an iOS, macOS, watchOS, tvOS, or visionOS app. API keys must only be used in trusted server environments.
For server-side Swift, initialize the full client with an API key:
import Foundation
import WorkOS
let workos = WorkOSClient(
apiKey: ProcessInfo.processInfo.environment["WORKOS_API_KEY"]!
)
let organization = try await workos.organizations.create(name: "Acme, Inc.")
print(organization.id)See GitHub Releases for details about each release.
The WorkOS iOS SDK follows Semantic Versioning. Breaking changes are released only in major versions; review the release notes before upgrading across a major version boundary.
Contributions are welcome. To run formatting checks, build the package, and execute the test suite locally:
script/ci