iOS

Beta Versions

Certain WorkOS features may be available only in the beta version of the SDK. Beta versions have the -beta.* suffix, for example, 3.2.0-beta.1. For more information on how to use beta versions, refer to the README in the GitHub repository.

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.

  1. Sign up for a WorkOS account.
  2. Create or select an application in the WorkOS Dashboard, then configure its redirect URI.
  3. Copy the application’s client ID and follow the AuthKit documentation.

Requirements

  • iOS 16+ / Mac Catalyst 16+ / macOS 13+ / tvOS 16+ / watchOS 9+ / visionOS 1+
  • Xcode 26+
  • Swift 6.2+

Swift Package Manager

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")
        ]
    )
]

AuthKit in a native app

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.

WorkOS API in a trusted environment

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