Initial setup
Integrating the SDK
Native SDK
The iOS SDK is a standard mergeable dynamic library, compatible with iOS 15.0 and higher. Xcode 16.4+ is required, but Batch will work with all Swift versions, along with Objective-C.
It supports the following architectures:
x86_64
arm64 (both for iOS, and iOS Simulator on Apple Silicon)
Catalyst is supported.
The iOS SDK also supports visionOS in a restricted usage since:
In-App messaging and mobile landings are unavailable.
In-App rating is not supported on visionOS due to an OS limitation.
Integrating with:
Use Xcode's Swift Package Manager wizard to add
https://www.github.com/BatchLabs/Batch-iOS-SDK.gitCocoaPods 1.15 required
First, simply add this line to your Podfile to integrate Batch in your project:
pod 'Batch', '~> 3.1'Then, run pod install in your Podfile folder, and open the .xcworkspace that was created. You're ready to go! In order to update Batch SDK, simply run pod update in that directory.
If you don't have a Podfile or are unsure on how to proceed, see the CocoaPods usage guide.
Note: Due to CocoaPods limitations, the Batch Pod is not a mergable library and has no code signing. If you need one of those, please use SPM or manually integrate the XCFramework.
Batch is only available on Carthage 0.30 and higher
Simply add this line to your Cartfile to integrate Batch in your project:
github "BatchLabs/Batch-iOS-SDK"Do not add Batch to the "carthage copy-frameworks" script input/output.
XCFramework distribution is supported since Batch 1.18.0 and Carthage 0.38.
Apple now requires Privacy Manifest that's not available with Carthage.
Your first start
Implement the Batch startWithAPIKey: method in your AppDelegate application:didFinishLaunchingWithOptions: method:
If you're making a SwiftUI app, you will need to add a delegate first.
import Batch
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
BatchSDK.start(withAPIKey: "YOUR_API_KEY")
[..]
}@import Batch;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Start Batch SDK.
[BatchSDK startWithAPIKey:@"MY_API_KEY"];
return YES;
}import SwiftUI
import Batch
class MyAppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
BatchSDK.start(withAPIKey: "YOUR_API_KEY")
return true
}
}
@main
struct BatchApp: App {
// Set an explicit delegate to integrate Batch in
@UIApplicationDelegateAdaptor(MyAppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}YOUR_API_KEY is your SDK API Key. You'll find it in ⚙ Settings → General.
Testing your integration
Congratulations on finishing the bulk of the integration!
If you want to validate your implementation before proceeding with the Push setup, you can locate the log that Batch posts in the Xcode console.
[Batch] Installation ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXBatch also provides a simple debug tool that allows you to test your integration (⚙ Settings → Debug) and a profile view that shows all the data available for a specific user ID.
Last updated

