iOS SDK integration instructions

This page describes how to integrate Mobile SDK with your project. Follow the instructions in this page to set up Mobile SDK to show ads in your app. For instructions on showing different ad types, see our various ad unit pages.

Requirements

  • This SDK requires Xcode version 15.0 or higher and your app should target iOS 12.0 or higher.
  • In order to show ads, you must have a valid Xandr placement ID.
  • Configure App Transport Security (ATS).

Installation

There are four ways to get our SDK:

CocoaPods

If you are unfamiliar with CocoaPods review their installation and user guides. Once you have CocoaPods installed:

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

    pod init
    
  2. Using a text editor, open the newly created podfile. Set the platform version to 12.0 and add pod 'AppNexusSDX' to the target.

    # iOS: Podfile config to include our SDK
    platform :ios, '12.0'
    project 'FunBanner'
    target 'FunBanner' do
      pod 'AppNexusSDK'
    end
    
  3. Save your changes and return to the Terminal and enter:

    pod install
    
  4. CocoaPods downloads the Xandr SDK and creates a workspace in the project directory. If your project is currently open, close it and open the workspace.

Carthage

If you are unfamiliar with Carthage review their installation and user guides. Once you've installed Carthage:

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

    touch Cartfile
    
  2. Open the file in Xcode to edit it.

    open -a Xcode Cartfile
    
  3. Add the following line to the file.

     # iOS: Carthage config to include our SDK
    github "appnexus/mobile-sdk-ios" 
    

    Tip

    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 does not recognize content within smart quotes and not perform correctly.

  4. Run below command.

    carthage update --use-xcframeworks
    
  5. To use AppNexusSDK SDK, add the AppNexusSDK.xcframework and OMSDK_AppNexus.xcframework to the Embedded Binaries (Target → General → Embedded Binaries) section by clicking the + icon.

  6. Drag the built .xcframework bundles from Carthage/Build into Embedded Binaries (Target → General → Embedded Binaries) section by clicking the + icon.

  7. If you are using Carthage for an application, select Embed & Sign, otherwise Do Not Embed.

XCFramework

  1. Download and unzip the latest version of AppNexusSDK.xcframework.zip of our SDK from Github Releases page. AppNexusSDK.xcframework.zip contains AppNexusSDK.xcframeworkAppNexusNativeSDK.xcframework, and OMSDK_AppNexus.xcframework.
  2. Open the app’s Xcode project or workspace.
  3. Go to the app target’s General configuration page.
  4. To use AppNexusSDK SDK, add the AppNexusSDK.xcframework and OMSDK_AppNexus.xcframework to the Embedded Binaries (Target → General → Embedded Binaries) section by clicking the + icon or to use AppNexusNativeSDK SDK, add the AppNexusNativeSDK.xcframework and OMSDK_.xcframework to the Embedded Binaries (Target → General → Embedded Binaries) section by clicking the + icon. Screenshot of the General configuration screen.
  5. Select Add Files from the drop-down and navigate to the location where you have the unzipped AppNexusSDK.xcframework and OMSDK_AppNexus.xcframework folders. Screenshot of the Add Files screen.
  6. Select the unzipped folders and click Open. Screenshot shows that the unzipped folder has been selected and opened.
  7. The added AppNexusSDK.xcframework and OMSDK_AppNexus.xcframework would be visible under the Framework, Libraries, and Embedded Content section. Screenshot shows that the added framework is visible in the Embedded content section.

Swift Package Manager

  1. Copy the URL https://github.com/appnexus/mobile-sdk-ios.git and check the latest version of SDK in Github Releases page.
  2. Open the app’s Xcode project or workspace. Select Project → Swift Package and click on + icon. Screenshot shows the steps to open a Swift Package project.
  3. Paste the Github URL https://github.com/appnexus/mobile-sdk-ios.git mentioned earlier in search bar of Choose Package Repository screen and click Next. Screenshot of the Choose Package Repository screen.
  4. Select the appropriate version from the drop-down (checked in Github Releases page as mentioned earlier) and click Next. Screenshot of the Choose Package Options screen.
  5. Select the applicable Package Product and click Finish to complete the setup. Screenshot of the Finish screen.
  6. The added AppNexusSDK package would be visible under the Framework, Libraries, and Embedded Content section. Screenshot shows that the package is visible in the Embedded Content section.

Set up for mediation (optional)

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