Getting started on iOS

How to use the THEOlive SDK in your iOS app.

Add dependency using SPM (Swift Package Manager)

Adding THEOliveSDK to an Xcode Project

  1. Open your Xcode project

  2. In the menu bar click File > Add Package Dependencies...

  3. Paste this URL in the search text field: https://github.com/THEOplayer/theolive-sdk-ios

  4. Click on Add Package.

  5. Select the target to which you want to add THEOliveSDK.

  6. Click on Add Package

Adding THSOliveSDK to a Swift Package

Add a dependencies clause to your Package and targets in the Package.swift manifest

// swift-tools-version:5.9
import PackageDescription

let package = Package(
  name: "MyPackage",
  dependencies: [
    .package(
      url: "https://github.com/THEOplayer/theolive-sdk-ios", 
      .upToNextMinor(from: "3.13.1") // or `.upToNextMajor
    )
  ],
  targets: [
    .target(
      name: "MyTarget",
      dependencies: [
        .product(name: "THEOliveSDK", package: "theolive-sdk-ios")
      ]
    )
  ]
)

Add dependency using CocoaPods

  • Create a Podfile if you don't already have one. From the root of your project directory, run the following command: pod init
  • Add THEOliveSDK as a dependency in your Podfile: pod 'THEOliveSDK', '1.0.0'
  • Install the pods using pod install , then open your .xcworkspace file to see the project in Xcode.

Embedding a player in your app

Import the SDK

import THEOliveSDK

Create a THEOlivePlayer

let player = THEOlivePlayer()

Create a view controller for the player using

let playerViewController = THEOlivePlayerViewController(player: player)

Then embed this view controller in one of your own view controllers

let yourViewController = UIViewController(nibName: nil, bundle: nil)

yourViewController.addChild(playerViewController)
yourViewController.view.addSubview(playerViewController.view)
playerViewController.didMove(toParent: yourViewController)

Controlling your player

To control the player use the player property of the THEOlivePlayerViewController. For more information of the player API you can download the API documentation here: THEOlive-3.15.0.doccarchive.zip

Examples

For sample Xcode projects see https://github.com/theoplayer/theolive-ios-samples.