Skip to main content
Primer Checkout iOS SDK is currently in beta (v3.0.0-beta.1). The API is subject to change before the stable release.

Prerequisites

  • iOS 15.0+ deployment target
  • Swift 6.0+
  • Xcode 16.0+
  • A clientToken from your server via the Client Session API
The Primer Checkout SDK uses SwiftUI. You can drop it into a SwiftUI view hierarchy directly, or present it from UIKit with PrimerCheckoutPresenter.

Install the SDK

Choose CocoaPods or Swift Package Manager. Both install the same PrimerSDK framework, which includes the Checkout Components UI.
This is a beta release line. The current version is 3.0.0-beta.1. Pin to the exact beta version so a new beta tag does not change your build without you opting in.

With CocoaPods

Add the following to your Podfile:
RUBY
use_frameworks!

target 'MyApp' do

  # 👇 Add this line
  pod 'PrimerSDK', '3.0.0-beta.1'

  # ...

end
Then run pod install to install PrimerSDK into your workspace:
pod install
Open the generated .xcworkspace (not the .xcodeproj) from now on.
In case you encounter an error that the bundle needs signing on Xcode 14, add the following post-install script to your Podfile.
RUBY
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
      target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
      end
    end
  end
end

With Swift Package Manager

Swift Package Manager is integrated into Xcode. To add PrimerSDK:
  1. Select your project, then navigate to Package Dependencies.
  2. Click the + button at the bottom-left of the Packages section.
  3. Paste https://github.com/primer-io/primer-sdk-ios.git into the search bar.
  4. Under Dependency Rule, choose Exact Version and enter the beta tag 3.0.0-beta.1.
  5. Press Add Package and let Xcode resolve and link the dependency.
Or declare it directly in your Package.swift:
dependencies: [
    .package(
        url: "https://github.com/primer-io/primer-sdk-ios.git",
        exact: "3.0.0-beta.1"
    )
]

Basic Usage

Import PrimerSDK and present PrimerCheckout with a clientToken. This renders the SDK’s default screens as a managed modal and reports the outcome through onCompletion:
import SwiftUI
import PrimerSDK

struct ContentView: View {
    let clientToken: String

    var body: some View {
        PrimerCheckout(clientToken: clientToken) { state in
            switch state {
            case .success(let result):
                print("Payment complete: \(result)")
            case .failure(let error):
                print("Checkout failed: \(error)")
            case .dismissed:
                print("Checkout dismissed")
            default:
                break
            }
        }
    }
}
PrimerCheckout requires iOS 15.0+ and runs on the main actor. Its full initializer also accepts primerSettings and primerTheme:
PrimerCheckout(
    clientToken: clientToken,
    primerSettings: PrimerSettings(),
    primerTheme: PrimerCheckoutTheme(),
    onCompletion: { state in
        // Handle the final checkout state
    }
)
ParameterTypeDefaultDescription
clientTokenString—The client token obtained from your backend via the Client Session API.
primerSettingsPrimerSettingsPrimerSettings()Configuration settings including payment options and UI preferences.
primerThemePrimerCheckoutThemePrimerCheckoutTheme()Theme configuration for design tokens.
onCompletion((PrimerCheckoutState) -> Void)?nilCalled when checkout completes with the final state (success, failure, or dismissed).
Building a UIKit app? Present the checkout from a UIViewController with PrimerCheckoutPresenter instead of embedding the SwiftUI view.

Verify Installation

Build and run your app to confirm the SDK is resolved and links correctly:
xcodebuild -scheme MyApp -destination 'generic/platform=iOS' build
If the build succeeds and import PrimerSDK resolves, the SDK is installed and ready to use.

Next Steps

API Overview

Tour the Checkout Components API surface

PrimerCheckout

The managed modal entry point in depth

Theming

Customize the appearance with design tokens

Handle Payment Result

Respond to success, failure, and dismissal