iOS Getting Started
This document details the process of integrating the MoPub SDK into your mobile application. If you have any questions, don’t hesitate to email us at email@example.com .
Here are the basic integration steps:
- Download the MoPub SDK
- Add the SDK to your Xcode project.
- Verify the viewability integration through your device logs
- Create and use a Banner or Interstitial ad.
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.
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 (includes Rewarded Video).
- Third party ad networks are not included. (See ‘Adding Third Party Ad Networks’ below if needing to use third party ad networks)
Includes everything you need to serve HTML and MRAID MoPub advertisements (includes Rewarded Video).
- Third party ad networks and Native MoPub advertisements are not included. (See ‘Adding Third Party Ad Networks’ below if needing to use third party ad networks)
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).
3. MoPub's SDK supports IOS 8.0 and above. Set the app's deployement target to minimum IOS 8.0 or above.
The MoPub Base SDK requires the following frameworks:
In addition, the third party networks require
You should now be ready to implement ad units into your application.
App Transport Security Settings
For App Transport Security related settings, please see this document for more information .
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 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 the GitHub Repository Source Code
- 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.
Adding Third Party Ad Networks
- Third party ad networks are supported via custom event adapters.
- Prebuilt custom event adapters for supported ad networks can be found in the ` AdNetworkSupport ` folder. (Please review: Supported Mediation Partners for details such as supported network SDK version)
To install a custom event you must:
- Download the desired third party SDK and add the header files and static libraries to your project. (Please review: Supported Mediation Partners for details such as supported network SDK version)
- Add the desired custom event to your project. You do this by cloning the `mopub-ios-sdk` repo and dragging the custom event `.h` and `.m` files from the relevant SDK folder under ` AdNetworkSupport `.
- Most integrations have two custom events, one for Banner ads and one for Interstitial ads.
- 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. Currently we only support subspecs Ad Colony and Chartboost.
Third Party Ad Networks and Cocoapods
MoPub maintains custom adapters for several third party networks. A number of them are available through our Cocoapod spec that provides a simple integration experience. To use these subspecs , add the desired subspecs from the list below to your podfile.
After adding the desired subspecs, the next time `pod install` or `pod update` is run Cocoapods will pull in the appropriate MoPub Custom Event classes and third party ad network SDK binaries. We will certify and update our list of supported third party ad networks as new pods become available.
Passing Location and Keywords
You can pass keywords from your app to MoPub as a comma-separated list in the ad view and use your user’s location to send more targeted ads from the MoPub Marketplace and certain ad networks.