iOS SDK Migration and Integration
This page describes how to integrate our SDK with your project.
For instructions on showing different ad types, see:
Follow the instructions in this section to set up our SDK to show ads in your app.
This SDK requires MacOS X 10.7+ and Xcode version 6.0+.
In order to show ads, you must have a valid Xandr placement ID.
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.
Step 1. Get and install the SDK
There are four ways to get our SDK:
- Download from source
- As a framework
If you are unfamiliar with CocoaPods review their installation and user guides. Once you have CocoaPods installed:
Use Terminal or your command line editor of choice, navigate to the root directory of your project and create a podfile.
Using a text editor, open the newly created podfile. Set the platform version to 9.0 and add pod 'AppNexusSDX' to the target.
Save your changes and return to Terminal and enter:
CocoaPods will download the Xandr SDK and create a workspace in the project directory. If your project is currently open, close it and open the workspace.
If you are unfamiliar with Carthage review their installation and user guides. 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.
Add the SDK to your project
Download from source
Download and unzip or clone the latest release of our SDK from our Github Release page.
Once the source from Github is downloaded, link the AppNexusSDK.Xcodeproj in your Xcode project.
- Open the app’s Xcode project or workspace. Right click on Project and Click on Add Files to "Project Name".
- Go to AppNexusSDK project folder and select the AppNexusSDK.Xcodeproj. Make sure to select Copy items if needed and select finish.
- Click Link Binary With Libraries (Target->General->Link Binary With Libraries) and select AppNexusSDK.framework.
As a framework
Download and unzip the latest version of AppNexusSDKFramework-x.y.z.zip of our SDK from Github Releases page. AppNexus Framework is distributed in three types:
Simulator: Contains only Simulator architectures i386 x86_64
- Device: Contains only phone architectures armv7 and arm64
- Universal: Contains both Simulator and device architectures
Use the one which is most appropriate for you testing. But Device framework needs to be used when doing app store submission.
2. Add the AppNexusSDK.framework to the Embedded Binaries:
a. Open the app’s Xcode project or workspace.
b. Go to the app target’s General configuration page.
c. Add the AppNexusSDK.framework to the Embedded Binaries(Target->General->Embedded Binaries) section by clicking the Add icon. Do not drag in the framework from Finder.
d. Select Add Other and navigate to the location where you have unzipped the AppNexusSDK.framework and select Open.
e. Select Copy items if needed and select Finish.
Remove unused simulators architectures if using universal framework.
Step 2. Add the required iOS frameworks.
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.
MillennialMedia.framework (if you use the Millennial SDK)
Developers working in Swift will require two additional frameworks:
Step 3. Add Linker Flags
In Xcode, under the Build Settings tab scroll down to the Linking sectionn and add -ObjC to the Other Linker Flags box.
Step 4. Set up for mediation (optional)
For instructions on getting set up for mediation, see Mediate with iOS.
Migrating from iOS SDK 5.x to 6.0
With the transition to a dynamic framework and the removal of the mediation adapters as part of the AppNexus SDK, apps using a Xandr 5.x version should follow these instructions for migrating their app to the Xandr 6.0 version.
There is no change for migrating from Xandr SDK 5.x to 6.0.
Download from source
To migrate from Xandr SDK 5.x to 6.0 from our source code:
- Remove the current Xandr SDK from your project.
- Follow the instructions for integrating the Xandr SDK from source.
- Navigate to the mediation folder and include the required mediation adapter files for your project.
As a framework
To migrate from Xandr SDK 5.x to 6.0 as a framework:
- Remove the current AppNexusSDK static library.
- Remove all the associated AppNexusSDK header files.
- Download the new AppNexusSDK dynamic framework.
- Change the imports from #import "ANBannerAdView.h" to #import <AppNexusSDK/AppNexusSDK.h>.