Support Home > SDK Integration > iOS – SDK Integration

iOS – SDK Integration

The Kochava iOS SDK is lightweight and can be easily integrated. The entire process takes less than 3 minutes, and simply requires adding the SDK to your project and then starting the tracker. If you have already integrated the SDK and started the tracker, please visit Using the SDK and choose a topic.

Integrating the SDK

Requirements:

  • Xcode 14.1 or higher

 

Supported Platforms:

  • iOS
  • tvOS
  • watchOS
  • macCatalyst
  • macOS

 

Supported Extensions:

  • Messages
  • Notification Content
  • Notification Service

 

Data Privacy:


Integration:

5 Minutes
Estimated Time to Complete
2 Minutes

The Kochava SDK is distributed as an XCFramework. A typical integration includes modules KochavaCore and KochavaTracker. Swift Packages is the preferred distribution method, but other options are available.

  • Module Swift Package
        Module is Optional

    KochavaCore
    Core SDK functionality.
    https://github.com/Kochava/Apple-SwiftPackage-KochavaCore
    KochavaTracker
    Attribution, event tracking, and analytics.
    https://github.com/Kochava/Apple-SwiftPackage-KochavaTracker
    KochavaAdNetwork (v5)
    Support for SKAdNetwork. This module is required for integrations which intend to leverage Apple’s SKAdNetwork support.
     
    This optional module was moved into module KochavaTracker in v6 and does not need to be added separately in newer versions.
    https://github.com/Kochava/Apple-SwiftPackage-KochavaAdNetwork
    KochavaEngagementExtension
    Push notification service and content extension support.
    https://github.com/Kochava/Apple-SwiftPackage-KochavaEngagementExtension

     

    How to add a Swift Package:

    If this is your first time adding a Swift Package, follow these steps for each of the modules above you wish to add:

    1. Copy the URL of the swift package to your pasteboard.
    2. In Xcode 12.2 or higher, go to File > Swift Packages > Add Package Dependency.
    3. Paste in the URL of the swift package into the prompt.
    4. Configure the version to the desired major version. Currently you should use .

     

    At this point the Kochava SDK integration is complete! When viewing code samples throughout our support site, always choose either [Swift] or [Objective-C] code samples.

    NOTE: It is important to sometimes perform a clean build when building for a new version of our SDK (Command – Shift – K). Apple’s package management system does not always automatically recognize that the packages have been updated

     

  • Module Cocoapod
        Module is Optional

    KochavaTracker
    Attribution, event tracking, and analytics.
    Apple-Cocoapod-KochavaTracker
    KochavaAdNetwork (v5)
    Support for SKAdNetwork. This module is required for integrations which intend to leverage Apple’s SKAdNetwork support.
     
    This optional module was moved into module KochavaTracker in v6 and does not need to be added separately in newer versions.
    Apple-Cocoapod-KochavaAdNetwork

    Deprecation Advisory: With the release of version 6.1.1 of the Kochava Apple SDK, the transition from Objective-C to Swift was complete, and we discontinued all static library products in favor of xcframeworks. Please contact support@kochava.com if you have any questions.

     

    Modules:

    Module iOS tvOS
        Module is Optional


    KochavaTracker
    Attribution, event tracking, and analytics.
    KochavaTrackeriOS

    KochavaTrackerTVOS

    KochavaAdNetwork (v5)
    Support for SKAdNetwork. This module is required for integrations which intend to leverage Apple’s SKAdNetwork support.
     
    This optional module was moved into module KochavaTracker in v6 and does not need to be added separately in newer versions.
    KochavaAdNetworkiOS

     

    How to add a Cocoapod:

    If this is your first time adding a Cocoapod, follow these steps for each of the modules above you wish to add:

    1. Open your Podfile in an editor. If you do not have a Podfile yet, see Using Cocoapods.
    2. Add the module, and configure the version to the desired major version. Currently you should use 7.

      Example:

    3. target 'MyApp' do
        pod 'Apple-Cocoapod-KochavaTracker', '~> 7.0'
      end

       

      Sample Code:

      XCFramework(s), Swift —

      import KochavaTracker

       

      XCFramework(s), Objective-C —

      @import KochavaTracker;

       

    At this point the v5 SDK integration is complete! When viewing code samples throughout our support site, always choose either Swift or Objective-C code samples.

  • Module XCFramework
        Module is Optional

    KochavaCore
    Core SDK functionality.

    KochavaTracker
    Attribution, event tracking, and analytics.

    KochavaAdNetwork (v5)
    Support for SKAdNetwork. This module is required for integrations which intend to leverage Apple’s SKAdNetwork support.
     
    This optional module was moved into module KochavaTracker in v6 and does not need to be added separately in newer versions.

     

    How to add an XCFramework:

    Follow these steps for each of the modules above you wish to add:

    1. Download the XCFramework from the link above and add it to your project.
      1. Download the release archive containing the XCFramework.
      2. Open the archive and copy the XCFramework into your Xcode project folder using Finder. You will typically want to add this file to the Frameworks folder of your project.
      3. Right click on your project in Xcode, select Add Files to (project name), and add the included file to your project.
      4. If you are working with multiple targets, you will want to ensure that you have included the XCFramework in each of the desired targets by selecting the file and reviewing its target membership in the inspector, which appears on the right side in Xcode.
      5. Ensure that the XCFramework is included in Frameworks, Libraries, and Embedded Content in your project target (located under the General tab). It will normally have been added at the moment you added the file to your target.


       

    2. Import the XCFramework.

     

    Sample Code:

    XCFramework(s), Swift —

    import KochavaTracker

     

    XCFramework(s), Objective-C —

    @import KochavaTracker;

     

  • Deprecation Advisory: With the release of version 6.1.1 of the Kochava Apple SDK, the transition from Objective-C to Swift was complete, and we discontinued all static library products in favor of xcframeworks. Please contact support@kochava.com if you have any questions.

     

    Module iOS Static Library tvOS Static Library
        Module is Optional

    KochavaCore
    Core SDK functionality.

    KochavaTracker
    Attribution, event tracking, and analytics.

    KochavaAdNetwork (v5)
    Support for SKAdNetwork. This module is required for integrations which intend to leverage Apple’s SKAdNetwork support.
     
    This optional module was moved into module KochavaTracker in v6 and does not need to be added separately in newer versions.

     

    How to add a Static Library:

    Follow these steps for each of the modules above you wish to add:

    1. Download the static library from the link above and add it to your project. We recommend integrating XCFrameworks rather than static libraries.
      1. Download the release archive containing the static library.
      2. Open the archive and copy the static library (including the folder wrapping it with the headers) into your Xcode project folder using Finder. You will typically want to add this to the root folder of your project, and we recommend placing it under a sub-folder named Kochava.
      3. Right click on your project in Xcode, select Add Files to (project name), and the included files to your project.
      4. If you are working with multiple targets, you will want to ensure that you have included the static library in each of the desired targets by selecting associated files and reviewing their target membership in the inspector, which appears on the right side in Xcode.
      5. Ensure that the included static library is included in Frameworks, Libraries, and Embedded Content in your project target (located under the General tab). It will normally have been added at the moment you added the file to your target.


       

    2. Import the static library’s main header file.
      The Kochava Apple SDK is natively written in Objective-C. You must import the main header file in order to access its symbols. If you’re using static libraries and you’re working in a project which contains Swift code, you must import this file in your Objective-C Bridging Header. For more information, see the Apple page Migrating your Objective-C Code to Swift.:

     

    Sample Code:

    Static Library(s), Objective-C —

    #import "KochavaTracker.h"
    #import "KochavaAdNetwork.h"  // optional

Starting the Tracker

1 Minute
Estimated Time to Complete
1 Minute

Once you have added the Kochava SDK to your project, the next step is to configure and start an instance of class KVATracker in code. Only your App GUID is required to start the tracker with the default settings, which is the case for typical integrations.

We recommend starting the tracker in the method within your AppDelegate that is called when your application did finish launching, although it can be done elsewhere if needed. Starting the tracker as early as possible will provide more accurate session reporting and help to ensure the tracker is actively processing tasks when subsequent requests are made. The call to start a tracker should be made one time when your application launches.

 

Start the Shared Instance:

  • import KochavaTracker
     
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        KVATracker.shared.start(withAppGUIDString: "_YOUR_APP_GUID_")
        return true
    }
    
  • @import KochavaTracker;
     
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        [KVATracker.shared startWithAppGUIDString:@"_YOUR_APP_GUID_"];
        return YES;
    }
    

Confirm the Integration

 

SDK WAYPOINT: At this point basic integration is complete and the Kochava SDK will begin reporting session activity and attributing installs.

 

Where to Go From Here:

Now that you have completed integration you are ready to utilize the many features offered by the Kochava SDK. Continue on to Using the SDK and choose a topic.

 
 

Last Modified: Oct 17, 2023 at 10:02 am