Integrate Vungle SDK for iOS

Use this article to easily integrate the Vungle SDK for iOS, whether you are using Objective-C or Swift.

Before You Begin

Requirements

  • The integration requires a Vungle account, so create a Vungle account if you haven’t already done so, and create a new iOS app in your account. Refer to the Add Your Apps and Placements section of our Using the Publisher Dashboard article to learn how to set up placements in the Vungle dashboard.
  • Vungle iOS SDK v.6.10.3 supports Xcode 13 as recommended by Apple
  • For apps using Xcode 13, using VungleSDK 6.10.3 is required as older SDKs do not support Xcode 13 for iOS 15 devices.
  • Vungle iOS SDK v.6.10.3 is fully compatible with the latest iOS version (iOS 15 as of the release date) and supports 64-bit apps.
  • Vungle iOS SDK v.6.10.3 supports applications that run on iOS 10 and higher. We do not recommend integrating the SDK for iOS versions lower than 10.0.
  • Vungle iOS SDK v.6.10.3 supports SKAdNetwork 3.0 and AppTrackingTransparency using Xcode 13.0.
  • For help answering the questions in Apple's App Store privacy questionnaire, refer to the data collection and use table in our Advanced Settings article.

Download the SDK

Download the Vungle SDK for iOS here: VungleSDK v.6.10.3.

Reference: Sample App and Source Code

Feel free to refer to the sample app we have provided as you integrate: https://github.com/Vungle/iOS-SDK. The source code referenced here is available in our public GitHub repository:

Step 1. Add the Vungle Framework to Your Xcode Project

Option 1: Cocoapods

The Vungle SDK is available through Cocoapods. Add the following into your project’s podfile:

pod "VungleSDK-iOS", "6.10.3"

After that, a quick pod install run will update your project with the latest version of our iOS SDK. At this point you can skip down to "Implement ATT Framework and Integrate SKAdNetwork IDs".

Note: Starting with VungleSDK 6.9.2+, Cocoapods requires a minimum version of 1.10.0 that provides pod support for XCFramework files. Testing was conducting using version 1.10.0+. 

In addition to the -ObjC flag, be sure to verify $(inherited) is included inside Other Linked Flags in the Build Settings

Option 2: Manual Integration

1. Add the VungleSDK.framework to Your Project

Download Vungle SDK v6.10.3. If you are updating from a previous version of the Vungle SDK, first remove the VungleSDK.framework or VungleSDK.xcframework directory completely before adding the new SDK.

Find the extracted files and drag the VungleSDK.framework or VungleSDK.xcframework directory into Xcode under Frameworks. Be sure to add the VungleSDK.framework or VungleSDK.xcframework folder as a group (yellow folder) and not as a reference (blue folder).

2. Add Other Required Frameworks

The Vungle SDK now ships with the build setting Link Frameworks Automatically set to YES; this means that you should no longer be required to link all the previously required frameworks and libraries (see below). With this update, you should only need to optionally link the following frameworks:

  • CoreFoundation.framework
  • Foundation.framework
  • StoreKit.framework

These previously required frameworks and libraries are included here so you can remove them if your project doesn’t reference any of them:

  • Support.framework
  • AudioToolbox.framework
  • AVFoundation.framework
  • CFNetwork.framework
  • CoreGraphics.framework
  • CoreMedia.framework
  • libz.dylib or libz.tbd
  • MediaPlayer.framework
  • QuartzCore.framework
  • StoreKit.framework
  • SystemConfiguration.framework

Note: Vungle SDK v.6.5.1+ does not support iOS 8 or lower. If you have iOS 7 as a deployment target, use Vungle iOS SDK v.4.1 or lower, and include these frameworks:

  • UIKit.framework
  • WebKit.framework
  • Foundation.framework

Confirm that the VungleSDK framework appears under Linked Frameworks and Libraries.

3. Add the “-ObjC” Linker Flag

Click on your project in Project Navigator and go to Build Settings → Linking → Other Linker Flags. Add -ObjC to Other Linker Flags.

Add SKAdNetwork IDs to Info.plist

Configure your app to participate in ad campaigns via the SKAdNetwork framework on iOS 14+. To do this, add the list of our approved partner IDs for advertising attribution to your Info.plist file. Adding the Vungle SKAdnetwork ID and the IDs of all the DSPs to whom you want to sell indicates that your app wants to work with Vungle and accept bids from these buyers.

Refer to Apple’s documentation on configuring the Info.plist properly for ad campaigns to be served. Refer also to the Xcode documentation for help on editing property lists.

Follow these steps to configure your app with SKAdNetworkIDs :

  1. Inside the Xcode Project navigator, open Info.plist file.
  2. Click the add button (+) next to a key in a property list inside the Info.plistfile in order to create a new property key. 
  3. Enter SKAdNetworkItems and select Array in the type column.
  4. Add a dictionary item, then add a single String item inside the dictionary.
  5. For each String item, add SKAdNetworkIdentifier as the key and the ad network identifier as the value.

Vungle hosts the Vungle SKAdNetwork ID and the list of our buyers' SKAdNetwork IDs in both JSON and XML formats on our website. Note that our lists are updated periodically:

Step 2. Add Code

Initialize the SDK

Initialize the SDK as soon as your app starts. If you are using a cache-optimized placement, initializing now gives the SDK enough time to cache an ad for that placement. You will need the App ID to initialize the SDK. You can find the App ID in the Vungle Dashboard.

- (BOOL)startWithAppId:(nonnull NSString *)appID error:(NSError **)error;

Sample code:

Objective-CSwift
#import <VungleSDK/VungleSDK.h> 
... 
NSError* error; 
NSString* appID = @"Your_AppID_Here"; 
VungleSDK* sdk = [VungleSDK sharedSDK]; 
if (![sdk startWithAppId:appID error:&error]) { 
    if (error) { 
        NSLog(@"Error encountered starting the VungleSDK: %@", error); 
    } 
}

Once the SDK is initialized successfully, the following callback method is called:

- (void)vungleSDKDidInitialize;

 

Swift Integration:

Starting with iOS VungleSDK v.6.10.1, a module map is being used to expose the header files in our framework. No bridging-header file is necessary for Swift integration.

In View Controller, import the VungleSDK module by adding the following

import VungleSDK

 

VungleSDK v.6.9.2 and below Swift Integration: Create a Bridging Header File

  1. Create a new Objective-C file in your project (File New File [Objective-C File]).
  2. When Xcode asks if you want to create a bridging header file between Objective-C and Swift, accept the prompt.
  3. Delete the new Objective-C file (${YOURPROJ}-Bridging-Header.m), but retain the bridging header file ${YOURPROJ}-Bridging-Header.h.
  4. In the Bridging header file, import the Vungle SDK by adding the following:
    #import <VungleSDK/VungleSDK.h>

Integrate Ad Formats

Complete your SDK integration for each ad format you plan to display in your app. Refer to our instructions for each ad format:

Further Customize Your Ads

Follow the instructions in our Advanced Settings article to fine-tune your app's integration with additional configuration options, such as GDPR, CCPA implementation, and many other settings.

Powered by Creativity Driven by Performance Sign Up Here

Questions?

Need further assistance, feel free to reach out to us, we’re here to help!

Was this article helpful?