Integrate the MoPub SDK for iOS

New: Check out the Integration Suite for a faster way to integrate the MoPub SDK.

Use these instructions to integrate the MoPub SDK with your iOS app. If you are upgrading to version 5.0.0 or higher of the SDK, refer to the SDK Initialization and GDPR sections for additional steps.


  • iOS 10.0 or higher
  • Xcode 11.0 or higher (SDK v5.9.0+)

High-Level Steps to Integrate

  1. Download the MoPub iOS SDK.
  2. Integrate the MoPub iOS SDK into your project.
  3. Integrate third-party networks and adapters.
  4. Optionally verify the viewability integration through your device logs.
  5. Configure App Transport Security (ATS).
  6. Configure Audio Session.
  7. Configure ad units in your app.

If you have any questions, don’t hesitate to email us at

Step 1. Download the MoPub iOS SDK

You can either download the MoPub SDK source as a zip file, choose to clone the Git repository, or use CocoaPods.

Option 1. Zipped Source

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

  • MoPub Base includes everything you need to serve Marketplace HTML, MRAID, and native MoPub advertisements. It excludes third-party ad networks.

  • MoPub Base SDK Excluding includes everything you need to serve HTML and MRAID advertisements. It excludes third-party ad networks and native MoPub advertisements.

Option 2. Clone the Git Repository

You can either use the bundled zips to install the MoPub SDK, or you can clone the Git repository as follows:

git clone git://

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

Option 3. CocoaPods

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

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

pod 'mopub-ios-sdk'

Option 4. MoPub SDK Frameworks

Starting with MoPub SDK v5.5, we are distributing three versions of the MoPubSDKFramework.framework, which you can download here. The three versions are:

  • Simulator: built with i386 and x86_64 architectures
  • Device: built with armv7 and arm64 architectures
  • Universal: includes simulator and device architectures

We recommend that you use the universal framework during development and testing process, and use the device framework when submitting to the app store.

Step 2. Integrate the MoPub iOS SDK into Your Project

You can either integrate the MoPub SDK into your project using the CocoaPods recommended implementation, the using Swift, or manually.

Option 1. Integrate the SDK Using CocoaPods

  • New CocoaPods setup: If you are setting up CocoaPods for the first time, run pod install.
  • Existing CocoaPods project: If you are adding MoPub to an existing CocoaPods project have CocoaPods, run pod update.

Your project is now ready to use the base MoPub SDK.

Option 2. Integrate Using Swift

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

The MoPub iOS SDK repository on GitHub also hosts and maintains a Swift sample app that you can reference.

Option 3. Integrate the SDK Manually

  1. Drag the MoPubSDK folder into your Xcode application group (be sure to select the Copy items into destination group’s folder option).



  2. Add the following frameworks to your project by clicking on your application’s target, then clicking Build Phases and expanding 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
  3. For apps using Manual Reference Counting (MRC), tell the compiler to build the MoPub iOS SDK source files with ARC. This is easy to do and has no impact on your application:

    1. Click on your application’s target, then click Build Settings.
    2. Set the Weak References in Manual Retain Release setting to ‘YES’.
    3. Click Build Phases and expand the Compile Sources group.
    4. Select all the MoPubSDK source files. (They are grouped together near the end if you have recently dragged in the SDK.)
    5. Scroll down and double-click on the last file. A blank popup appears.
    6. Enter -fobjc-arc and press [Enter] to add the -fobjc-arc flag to all the selected files.

Step 3. Integrate Third-Party Ad Networks and Adapters

Refer to this tutorial for the integration details.

Step 4. Optionally Verify Viewability

This section contains legacy information. Starting from MoPub 5.13.0, the Moat and IAS viewability SDKs have been removed. Viewability tracking logic is no longer operational via these proprietary SDKs.

Optionally verify the viewability integration through your device logs.

Step 5. Configure App Transport Security (ATS)

App Transport Security (ATS), introduced in iOS 9, is a default setting that requires apps to make network requests only via HTTPS. To ensure that ads work properly, we strongly recommend the following ATS configuration.

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


You can also edit Info.plist directly in Xcode. Set the key’s boolean flag to ‘YES’. Keep in mind that, starting in iOS 10, NSAllowsArbitraryLoads is ignored if one or more of the following is present:

  • NSAllowsArbitraryLoadsForMedia
  • NSAllowsArbitraryLoadsInWebContent
  • NSAllowsLocalNetworking

Refer to the Apple documentation.

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.

Step 6. Configure Audio Session

MoPub uses the Apple iOS WKWebView to render HTML (including MRAID) and VAST video creative. As designed by Apple, WKWebView respects the volume settings only and does not respect the Audio Session Category set by the application.

Fullscreen and Rewarded Ads with rich media experiences or VAST video may include an audio component as such it is important to handle audio interruptions gracefully, Apple provides a Programming Guide for responding to audio interruptions.

Step 7. Configure Ad Units in Your App

Once you’ve completed the above steps, you can start displaying ads in your application by configuring the ad units as shown in the link below for your ad format:

Rate Limiting

MoPub SDK imposes minimum wait times in between subsequent requests when an ad request is not filled. To avoid this from happening please follow these steps.

This section contains legacy information. Starting from MoPub 5.13.0, the Moat and IAS viewability SDKs have been removed. Viewability tracking logic is no longer operational via these proprietary SDKs.

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.

Last updated September 25, 2020

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.

© 2020 MoPub (a division of Twitter, Inc.)