Prerequisites
- iOS 15.0+ deployment target
- Swift 6.0+
- Xcode 16.0+
- A
clientTokenfrom 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 samePrimerSDK 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 yourPodfile:
RUBY
pod install to install PrimerSDK into your workspace:
.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
With Swift Package Manager
Swift Package Manager is integrated into Xcode. To addPrimerSDK:
- Select your project, then navigate to Package Dependencies.
- Click the + button at the bottom-left of the Packages section.
- Paste https://github.com/primer-io/primer-sdk-ios.git into the search bar.
- Under Dependency Rule, choose Exact Version and enter the beta tag
3.0.0-beta.1. - Press Add Package and let Xcode resolve and link the dependency.
Package.swift:
Basic Usage
ImportPrimerSDK and present PrimerCheckout with a clientToken. This renders the SDK’s default screens as a managed modal and reports the outcome through onCompletion:
PrimerCheckout requires iOS 15.0+ and runs on the main actor. Its full initializer also accepts primerSettings and primerTheme:
| Parameter | Type | Default | Description |
|---|---|---|---|
clientToken | String | — | The client token obtained from your backend via the Client Session API. |
primerSettings | PrimerSettings | PrimerSettings() | Configuration settings including payment options and UI preferences. |
primerTheme | PrimerCheckoutTheme | PrimerCheckoutTheme() | Theme configuration for design tokens. |
onCompletion | ((PrimerCheckoutState) -> Void)? | nil | Called when checkout completes with the final state (success, failure, or dismissed). |
Verify Installation
Build and run your app to confirm the SDK is resolved and links correctly: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