The Adjust iOS SDK enables you to record attribution, events, and more in your iOS app. This guide shows you how to integrate the Adjust SDK with your app.
1. Add the SDK to your project
To use the Adjust SDK in your iOS app, you need to add it to your Xcode project.
To add the SDK using Swift’s package manager:
Select File —> Swift Packages —> Add Package Dependency
In the box that appears, enter the SDK’s GitHub address: https://github.com/adjust/ios_sdk
Select the version of the Adjust SDK you want to use in the Version dropdown. Check the releases page for the latest version.
To import the Adjust SDK, add the following to your bridging header file:
If you use the Adjust Web Bridge, add the following to your bridging header file:
If you use the Adjust SDK in a tvOS app, add the following to your bridging header file:
If you use the Adjust SDK in a iMessage app, add the following to your bridging header file:
To import the Adjust SDK, add the following to your AppDelegate.h file:
If you use the Adjust Web Bridge, add the following to your AppDelegate.h file:
If you use the Adjust SDK in your tvOS app, add the following to your AppDelegate.h file:
If you use the Adjust SDK in your iMessage app, add the following to your AppDelegate.h file:
3. Add iOS frameworks
The Adjust SDK depends on frameworks to access certain device information. To enable reading this information, add the frameworks and mark them as optional.
Framework
Description
Notes
AdSupport.framework
Enables access to the device’s IDFA. Also enables access to LAT information on devices running iOS 14 or earlier.
Don’t add this framework if your app targets the “Kids” category.
AdServices.framework
Handles ASA attribution.
StoreKit.framework
Enables access to the SKAdNetwork framework.
Required to allow the Adjust SDK to handle communication with SKAdNetwork on devices running iOS 14 or later.
AppTrackingTransparency.framework
Required to allow the Adjust SDK to wrap user ATT consent dialog and access consent responses on devices running iOS 14 or later
Don’t add this framework if your app targets the “Kids” category
WebKit.framework
Enables the use of web views in your application
Only required if your app uses web views
4. Initialize the Adjust SDK
To initialize the Adjust SDK, you need to create a config object. This object contains configuration options that control how the Adjust SDK behaves. Pass the following arguments for a minimal setup:
If your app targets iMessage, there are some additional settings you must configure:
If you added the Adjust SDK from source, add the ADJUST_IM=1 pre-processor macro to your iMessage project settings.
If you added the Adjust SDK as a framework, make sure to add New Copy Files Phase in your Build Phases project settings. Set the AdjustSdkIm.framework to be copied to the Frameworks folder.
Record sessions
The Adjust SDK isn’t subscribed to iOS system notifications in iMessage apps. To notify the Adjust SDK when your app has entered or left the foreground, you need to call the trackSubsessionStart and trackSubsessionEnd methods.
Add a call to trackSubsessionStart inside your didBecomeActiveWithConversation: method:
You can also use the included WebViewJavascriptBridge by setting the bridgeRegister property of your AdjustBridge instance. See the library’s documentation for usage information.
Integrate AdjustBridge into your web view
To use the Javascript bridge in your web view, you need to configure the bridge. Add the following Javascript code to initialize the Adjust iOS web bridge:
Once you’ve added your config object and initialization logic, you can configure the Adjust SDK to record information about different parts of your app. Check out the guides for the SDK’s configuration features and recording features to set up exactly what you want to record.
6. Test the Adjust SDK
Now that you’ve configured the Adjust SDK to record information about your app, it’s time to test it. Adjust offers a testing console and a Device API to help you test your app.
Follow the testing guide to make sure Adjust receives the expected values back from your app.
7. Build your app for production
Once you’ve finished your testing, you can build your app for production. To do this, you need to update your config object.
Update the following values:
environment: Set this to ADJEnvironmentProduction.
logLevel: Choose a logging level, or disable logging completely by passing an allowSuppressLogLevel argument in your config object.