Getting Started

What’s new in 5.0

Publishers upgrading to the 5.0 MoPub SDK are required to take additional steps. Reference our guides for SDK Initialization and GDPR for more details on how to stay up-to-date and compliant.

Introduction

This document details the process of integrating the MoPub SDK with your mobile application. If you have any questions, don’t hesitate to email us at support@mopub.com.

Here are the basic integration steps:

  1. Download the MoPub SDK
  2. Add the SDK to your Xcode project.
  3. Verify the viewability integration through your device logs
  4. Create and use a Banner or Interstitial ad.

Disclosure

MoPub SDK v4.16 and above integrates technology from our partners Integral Ad Science, Inc. (“IAS”) and Moat, Inc. (“Moat”) in order to support viewability measurement and other proprietary reporting that IAS and Moat provide to their advertiser and publisher clients. You have the option to remove or disable this technology by following the opt-out instructions.

If you do not remove or disable IAS’s and/or Moat’s technology in accordance with these instructions, you agree that IAS’s privacy policy and license and Moat’s privacy policy, terms, and license, respectively, apply to your integration of these partners’ technologies into your application.

Download the MoPub iOS SDK

The MoPub SDK is distributed as source code that you must include in your application. MoPub provides two prepackaged archives of source code:

Includes everything you need to serve HTML, MRAID, and Native MoPub advertisements. Third party ad networks are not included.

Includes everything you need to serve HTML and MRAID advertisements. Third party ad networks and Native MoPub advertisements are not included.

Requirements and Dependencies

  • iOS 8.0 and up
  • Xcode 9.0 and up

Incorporate the MoPub iOS SDK

These instructions assume that you have downloaded one of the MoPub SDK zip archives.

  1. Download and unzip the MoPub iOS SDK.

  2. Drag the MoPubSDK folder into your Xcode application group (be sure to check the “Copy items into destination group’s folder” option).

    image

    image

  3. Add the following frameworks to your project. To do this, click on your application’s target, then click on Build Phases and expand the Link Binary With Libraries group. The MoPub Base SDK requires the following frameworks:

    • AdSupport.framework
    • AVFoundation.framework
    • CoreGraphics.framework
    • CoreLocation.framework
    • CoreMedia.framework
    • CoreTelephony.framework
    • Foundation.framework
    • MediaPlayer.framework
    • MessageUI.framework
    • QuartzCore.framework
    • SafariServices.framework
    • StoreKit.framework
    • SystemConfiguration.framework
    • UIKit.framework
    • WebKit.framework

You should now be ready to implement a Banner or Interstitial ad. To mediate a third party network that is not supported, you can build a Custom Event.

App Transport Security Settings

App Transport Security (ATS), introduced in iOS 9, is a default setting which requires apps to make network requests only via HTTPS.

UPDATED: Apple has extended the ATS deadline indefinitely. We recommend publishers disable ATS to ensure ads are served correctly.

Use the following ATS key/value in your app’s Info.plist file

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

The Info.plist can also be edited directly in Xcode. Set the key’s boolean flag to YES.

image

The above settings will disable ATS on iOS 9 and iOS 10 for the app.

ATS Setting Justification

Publishers will have to provide justification during the App Store review process for setting any of these ATS keys to YES in any MoPub SDK version. Per Apple’s App Store Review for ATS documentation, loading web content from a variety of sources (for ads) is an acceptable justification.

Additional Information

For more information about ATS and these settings, see our ATS help article.

For Applications that use MRC

If your application uses Manual Reference Counting (MRC) you must tell the compiler to build the MoPub iOS SDK source files with ARC. This has no impact on your application and can be done relatively easily:

First, click on your application’s target, then click on Build Settings. Set the Weak References in Manual Retain Release setting to YES. Next, click on Build Phases and expand the Compile Sources group. Now select all the MoPubSDK source files. These will be grouped together near the end if you have recently dragged the SDK in.

Once the files are selected scroll down and double click on the last file. You should see a blank popup appear. Enter -fobjc-arc and hit return. This should add the -fobjc-arc flag to all the selected files.

Using Git

While the bundled zips are the preferred method to install the MoPub SDK you can, instead, clone the git repository:

git clone git://github.com/mopub/mopub-ios-sdk.git

The installation instructions are similar to the ones outlined above for the zip archives. To install the base SDK you must drag in the contents of the MoPubSDK folder.

Using CocoaPods

The MoPub SDK is available through Cocoapods, a popular dependency management system for Objective-C projects.

To download and incorporate the MoPub SDK into your project using Cocoapods, add the following line to your project’s podfile:

pod 'mopub-ios-sdk'

After running pod install (if you’re setting up Cocoapods for the first time) or pod update (if you’re adding MoPub to an existing Cocoapods project), your project will be ready to use the base MoPub SDK.

Adding Third Party ad Networks

Please refer to the following tutorial for the integration details.

Swift Integration

To use the MoPub SDK in your Swift project, simply import MoPubSDK/MoPub-Bridging-Header.h to your project and ensure the Objective-C Bridging Header build setting under Swift Compiler - Code Generation has a path to the header

Last updated December 05, 2018

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2018 MoPub Inc.