Getting started on iOS

This page explains how to install the Smart Instream SDK into an iOS application. This is the first step to complete before delivering instream ads in your video content.

  1. Prerequisites
  2. App Transport Security
  3. Installation with Cocoapods

Prerequisites

There are some prerequisites before installing the instream SDK.

  • You use Xcode 9.0 or higher.
  • Your app targets iOS 8.0 or higher for iOS apps, or tvOS 9.0 or higher for tvOS apps.
  • You installed Cocoapods on your computer.

App Transport Security

App Transport Security (ATS) is a feature to protect user privacy introduced in iOS 9. ATS will block every non HTTPS connections. It is enabled by default for iOS applications and enforces secure connections.

Eventhough the ad industry tends to full HTTPS support, it happens that some medias are not hosted on secured servers. To avoid your video ads being blocked by ATS you should configure exceptions in your app's Info.plist file.


Under App Transport Security Settings of your Info.plist, make sure you enable the exceptions for:

  • Allow Arbitrary Loads and
  • Allow Arbitrary Loads For Media


Your Info.plist should contains these keys:


<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsForMedia</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

The NSAllowsArbitraryLoads exception is required to make sure your ads will not be blocked by ATS on iOS 9 whereas NSAllowsArbitraryLoadsForMedia will make sure your ads are not blocked on devices with iOS 10 and higher.

Installation with Cocoapods

To import the Smart Instream SDK into your iOS project, please use Cocoapods.

CocoaPods is a dependency manager for Swift and Objective-C Xcode projects. You can read Cocoapods official documentation for information on how to setup Podfiles.


  • For iOS apps, add in your project's Podfile the following line:
    pod 'Smart-Instream-SDK'
    For tvOS apps, add in your project's Podfile the following line instead:
    pod 'Smart-Instream-TV-SDK'

    You can import both these SDKs for different targets if needed, but they obviously can't be imported both in the same target.

  • Open a terminal window and cd to your project's directory.
  • Then from the command line, run:
    $ pod install --repo-update

    This will install all the dependencies and frameworks required for the Smart Instream SDK to work.

  • You can now proceed with the integration of your ads directly within your project's workspace.