Skip to end of metadata
Go to start of metadata

iOS SDK Integration (pre 6.0)

This page describes how to integrate our SDK with your project.

For instructions on showing different ad types, see:

On This Page

Initial Integration

Follow the instructions in this section to set up our SDK to show ads in your app.

Requirements

This SDK requires MacOS X 10.7+ and Xcode version 6.0+.

In order to show ads, you must have a valid AppNexus placement ID. This is numeric ID that represents a context in an application where ads can be shown.

App Transport Security

iOS 9 introduced a new privacy feature called App Transport Security (ATS). ATS blocks non-HTTPS requests by default.

To show ads using our SDK, you must include the following exception in the info.plist file of each app which contains our SDK:

If you are using v2.13 or greater of our SDK and would like to show only ATS-compliant ads, you can enable HTTPS ads in your app using the instructions in Request Ads over HTTPS.

Installation

Step 1. Get the SDK

There are three ways to get our SDK:

  1. Download and unzip the latest release of our SDK from our Github Releases page. If you don't want the binary release, you can clone the source code from our Github repo and build it yourself.
  2. Use CocoaPods.

    Once you have CocoaPods installed.

    Use Terminal or your command line editor of choice and navigate to the project directory and create a podfile. 

    Using a text editor, open the newly created podfile. Set the platform to 9.0 (AppNexus always supports two iOS releases back from the current release) and add pod 'AppNexusSDX' to the target. 

    Save your changes and return to Terminal and enter: 

    Cocoapods will download the AppNexus SDK and create a workspace in the project directory. If your project is currently open, close it and open the workspace. 

  3. Use Carthage. Open the Terminal.app and navigate to the root directory of your project. Create a Cartfile. 

    Open the file in Xcode to edit it. 

    Add the following line to the file.

    Note: You can use editor's other than Xcode to edit the Cartfile but be aware that other editing programs such as TextEdit might automatically include smart quotes instead of straight quotes. Carthage will not recognize content within smart quotes and not perform correctly. 

    Add the SDK to your project

 

Step 2. Add the SDK to your project

If you used CocoaPods or Carthage in Step 1, you can ignore this step.

Drag the unzipped folder onto your project in Xcode. Make sure you check the box Copy items if needed (At least that's what it's called in Xcode 8).

 

Step 3. Add the AppNexus SDK framework and the required iOS frameworks.

Add the AppNexus SDK framework, and then add the iOS frameworks listed below. To add them, click your application's target. Then click Build Phases, and Link Binary with Libraries to enter the frameworks.

The list below includes all frameworks and libraries required to build the full SDK tarball as released to Github. You may not need all of these if you are building the SDK yourself, without all of the third-party SDK integrations.

  • AdSupport.framework

  • AudioToolbox.framework

  • AVFoundation.framework

  • CFNetwork.framework

  • CoreGraphics.framework

  • CoreTelephony.framework

  • EventKit.framework

  • Foundation.framework

  • iAd.framework

  • MediaPlayer.framework

  • MessageUI.framework

  • MobileCoreServices.framework

  • PassKit.framework

  • QuartzCore.framework

  • Security.framework

  • Social.framework

  • StoreKit.framework

  • SystemConfiguration.framework

  • UIKit.framework

  • MillennialMedia.framework (if you use the Millennial SDK)

  • CoreMedia
  • libz.tbd

Developers working in Swift will require two additional frameworks:

  • EventKitUI.framework
  • WebKit.framework

Step 4. Add Linker Flags

In Xcode, under the Build Settings tab, you can either:

  • Choose All, and scroll down to the Linking section, and choose Other Linker Flags
  • Enter "other linker flags" in the search box

In the Other Linker Flags box, add the -ObjC flag.

Step 5. Set up for mediation (optional)

For instructions on getting set up for mediation, see Mediate with iOS.

Related Topics