Klarna Docs - iOS - Getting Started

iOS - Getting Started



If you’re using Cocoapods, you can add the SDK by adding the dependency to your Podfile:

pod "KlarnaMobileSDK"

Followed by performing:

pod install

You should then be able to import the KlarnaMobileSDK module in your workaspace.


If you’re using Carthage, you can add the SDK to your Cartfile as below:

binary "https://raw.githubusercontent.com/klarna/klarna-mobile-sdk/master/KlarnaMobileSDK.json"

Followed by performing:

carthage update

You should be then able to add the .framework to your project.

Swift Package Manager

In Xcode, navigate to File → Swift Packages → Add Package Dependency and enter the repository URL:


In Version, Select Up to Next Major and take the default option. Then choose KlarnaMobileSDK in the Package Product column.

More information

We’re building the SDK with Module Stability and ensuring that it will work with any Xcode 11+ version and Swift compilers.

The SDK also supports multiple versions of Xcode and Swift if needed. All of these are the same SDK version but generated with different toolchains. You can see the default version in the podspec. However, if you want to use a specific Xcode build, we offer subspecs (that you can see in the project’s podspec) for your particular toolchain.

For more information, check out the Klarna Mobile SDK Github repository.


Return URL

Both the hybrid and native integrations might, at some point, open third-party applications. To automatically return the user, these third-party applications need to know about your app’s shema.

To do that, you’ll need to provide the SDK with what we call a “return URL” parameter. If you haven’t done so already, you can add the schema to your app’s plist.




The SDK requires camera access to be used in Card Scan when available. Please add NSCameraUsageDescription with a description to your Info.plist.

Klarna app Integration

To use the Klarna app to improve user experience during the authorization process, you must add Klarna’s app scheme (klarna, klarnaconsent) to your application Info.plist file as an entry in the list LSApplicationQueriesSchemes

Once the values above are added, It will allow the SDK integration to properly identify if the Klarna app is installed and then perform an app switch for authorization and then return to your application with the response.


Importing the SDK

Both the Klarna Payments native integration and the hybrid integration are available under the KlarnaMobileSDK module.

A Common Class For Cross-cutting Concerns

Some features in the SDK are relevant for both native and hybrid integrations of the SDK. These are accessible under the CommonMobileSDKCommon class. These features are:

  • Setting a logging level.
  • Reading the device identifier.

1. Reading the Device Indentifier

You can read the device identifier with the static function deviceIdentifier() on your KlarnaMobileSDKCommon.

This device identifier is stored in user defaults.

Read the Identifier

2. Setting the Logging Level

The SDK will log events and errors to the system’s log while it’s running. You can read these through XCode’s console or the Console app in Mac OS. You can set the logging level for the SDK through the setLoggingLevel() static function on KlarnaMobileSDKCommon

Set Level

loggingLevelKlarnaLoggingLevelThe type of events or level the SDK should log at.

KlarnaLoggingLevel values

off / KlarnaLoggingLevelOffNothing will be logged into console.
error / KlarnaLoggingLevelErrorOnly errors will be logged into console.
verbose / KlarnaLoggingLevelVerboseEverything will be logged into console.