Install & configure iOS SDK
Adapty SDK includes two key modules for seamless integration into your mobile app:
- Core Adapty: This essential SDK is required for Adapty to function properly in your app.
- AdaptyUI: This optional module is needed if you use the Adapty Paywall Builder, a user-friendly, no-code tool for easily creating cross-platform paywalls.
Want to see a real-world example of how Adapty SDK is integrated into a mobile app? Check out our sample apps, which demonstrate the full setup, including displaying paywalls, making purchases, and other basic functionality.
For a complete implementation walkthrough, you can also see the videos:
- iOS (SwiftUI)
- iOS (UIKit)
Requirements
While the SDK technically supports iOS 13.0+ for the core module, iOS 15.0+ is effectively required for practical use since:
- All StoreKit 2 features require iOS 15.0+
- AdaptyUI module is iOS 15.0+ only
Install Adapty SDK
- Swift Package Manager (recommended)
- CocoaPods (legacy)
In Xcode, go to File -> Add Package Dependency.... Note that the steps to add package dependencies may vary between Xcode versions, so refer to Xcode documentation if needed.
- Enter the repository URL:
https://github.com/adaptyteam/AdaptySDK-iOS.git
- Select the version (latest stable version is recommended) and click Add Package.
- In the Choose Package Products window, select the modules you need:
- Adapty (mandatory - always select this)
- AdaptyUI (optional - only if you plan to use Paywall Builder)
- Click Add Package to complete the installation.
- Verify installation: In your project navigator, you should see "Adapty" (and "AdaptyUI" if selected) under Package Dependencies.
CocoaPods is now in maintenance mode, with development officially stopped. We recommend switching to Swift Package Manager.
-
Add Adapty to your
Podfile
. Choose the modules you need:- Adapty is the mandatory module.
- AdaptyUI is an optional module you need if you plan to use the Adapty Paywall Builder.
Podfilepod 'Adapty'
pod 'AdaptyUI' # optional module needed only for Paywall Builder -
Run:
Shellpod install
This will create a .xcworkspace
file for your app. Use this file for all future development.
Activate Adapty module of Adapty SDK
- SwiftUI
- UIKit
import SwiftUI
import Adapty
@main
struct YourApp: App {
init() {
// Configure Adapty SDK
let configurationBuilder = AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY") // Get from Adapty dashboard
Adapty.logLevel = .verbose // recommended for development and the first production release
let config = configurationBuilder.build()
// Activate Adapty SDK asynchronously
Task {
do {
try await Adapty.activate(with: configurationBuilder)
} catch {
// Handle error appropriately for your app
print("Adapty activation failed: ", error)
}
}
var body: some Scene {
WindowGroup {
// Your content view
}
}
}
}
// In your AppDelegate class:
// If you only use an AppDelegate, place the following code in the
// application(_:didFinishLaunchingWithOptions:) method.
// If you use a SceneDelegate, place the following code in the
// scene(_:willConnectTo:options:) method.
import Adapty
Task {
do {
let configurationBuilder = AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY") // Get from Adapty dashboard
.with(logLevel: .verbose) // recommended for development and the first production release
let config = configurationBuilder.build()
try await Adapty.activate(with: config)
} catch {
// Handle error appropriately for your app
print("Adapty activation failed: ", error)
}
}
To get your Public SDK Key:
- Go to Adapty Dashboard and navigate to App settings → General.
- From the Api keys section, copy the Public SDK Key (NOT the Secret Key).
- Replace
"YOUR_PUBLIC_SDK_KEY"
in the code.
- Make sure you use the Public SDK key for Adapty initialization, the Secret key should be used for server-side API only.
- SDK keys are unique for every app, so if you have multiple apps make sure you choose the right one.
Activate AdaptyUI module of Adapty SDK
If you plan to use Paywall Builder and have installed AdaptyUI module, you also need to activate AdaptyUI.
In your code, you must activate the core Adapty module before activating AdaptyUI.
- SwiftUI
- UIKit
import SwiftUI
import Adapty
import AdaptyUI
@main
struct YourApp: App {
init() {
// ...ConfigurationBuilder steps
// Activate Adapty SDK asynchronously
Task {
do {
try await Adapty.activate(with: configurationBuilder)
try await AdaptyUI.activate()
} catch {
// Handle error appropriately for your app
print("Adapty activation failed: ", error)
}
}
// main body...
}
}
// If you only use an AppDelegate, place the following code in the
// application(_:didFinishLaunchingWithOptions:) method.
// If you use a SceneDelegate, place the following code in the
// scene(_:willConnectTo:options:) method.
import Adapty
import AdaptyUI
Task {
do {
let configurationBuilder = AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY") // Get from Adapty dashboard
.with(logLevel: .verbose) // recommended for development
let config = configurationBuilder.build()
try await Adapty.activate(with: config)
try await AdaptyUI.activate()
} catch {
// Handle error appropriately for your app
print("Adapty activation failed: ", error)
}
}
Optionally, when activating AdaptyUI, you can override default caching settings for paywalls.
Optional setup
Logging
Set up the logging system
Adapty logs errors and other important information to help you understand what is going on. There are the following levels available:
Level | Description |
---|---|
error | Only errors will be logged |
warn | Errors and messages from the SDK that do not cause critical errors, but are worth paying attention to will be logged |
info | Errors, warnings, and various information messages will be logged |
verbose | Any additional information that may be useful during debugging, such as function calls, API queries, etc. will be logged |
let configurationBuilder = AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY")
.with(logLevel: .verbose) // recommended for development
Redirect the logging system messages
If you need to send Adapty's log messages to your system or save them to a file, use the setLogHandler
method and implement your custom logging logic inside it. This handler receives log records containing message content and severity level.
Adapty.setLogHandler { record in
writeToLocalFile("Adapty \(record.level): \(record.message)")
}
Data policies
Adapty doesn't store personal data of your users unless you explicitly send it, but you can implement additional data security policies to comply with the store or country guidelines.
Disable IDFA collection and sharing
When activating the Adapty module, set idfaCollectionDisabled
to true
to disable IDFA collection and sharing.
Use this parameter to comply with App Store Review Guidelines or avoid triggering the App Tracking Transparency prompt when IDFA isn't needed for your app. The default value is false
. For more details on IDFA collection, refer to the Analytics integration section.
let configurationBuilder =
AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY")
.with(idfaCollectionDisabled: true)
Disable IP collection and sharing
When activating the Adapty module, set ipAddressCollectionDisabled
to true
to disable user IP address collection and sharing. The default value is false
Use this parameter to enhance user privacy, comply with regional data protection regulations (like GDPR or CCPA), or reduce unnecessary data collection when IP-based features aren't required for your app.
let configurationBuilder =
AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY")
.with(ipAddressCollectionDisabled: true)
Media cache configuration for paywalls in AdaptyUI
Please note that the AdaptyUI configuration is optional. You can activate the AdaptyUI module without its config. However, if you use the config, all parameters are required.
import AdaptyUI
// Configure AdaptyUI
let adaptyUIConfiguration = AdaptyUI.Configuration(
mediaCacheConfiguration: .init(
memoryStorageTotalCostLimit: 100 * 1024 * 1024,
memoryStorageCountLimit: .max,
diskStorageSizeLimit: 100 * 1024 * 1024
)
)
// Activate AdaptyUI
AdaptyUI.activate(configuration: adaptyUIConfiguration)
Parameters:
Parameter | Presence | Description |
---|---|---|
memoryStorageTotalCostLimit | required | Total cost limit of the storage in bytes. |
memoryStorageCountLimit | required | The item count limit of the memory storage. |
diskStorageSizeLimit | required | The file size limit on disk of the storage in bytes. 0 means no limit. |