Running Sample Apps for the Native SDK for iOS/tvOS

In this topic, you will learn how to run the sample apps associated with the Brightcove Native SDK for iOS/tvOS. These samples provide a good starting point for creating your own apps.

Overview

The Brightcove Native SDK for iOS/tvOS provides a variety of sample apps to help you get started with your own implementations. For a complete list of samples, see the following:

If you are new to the Brightcove Native SDKs, check out the Getting Started with the Native SDKs videos.

Tools needed

You will need the following tools installed on your computer to run the sample apps:.

  • Xcode 8.0 or later

    Xcode is an integrated development environment (IDE) used to create software for macOS, iOS, watchOS and tvOS.
  • CocoaPods 1.0 or later

    CocoaPods is a dependency manager used to add the Brightcove SDK framework along with other needed libraries. You can add libraries to your project manually, but CocoaPods makes it easier.

Sample types

In the player samples for iOS/tvOS repository, you will find samples for the following platforms:

  • iOS - A mobile operating system for Apple devices, including iPhone, iPad and iPod

  • tvOS - An operating system for Apple TV

The samples are written in the following languages:

  • Objective-C

    Objective-C is a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime. So, it adds syntax for defining classes and methods.
  • Swift

    Swift is the new open source programming language for iOS, Mac, tvOS and Apple watch. It is more intuitive to use and is similar to JavaScript. It can be added to existing Objective-C code.

Adding library dependencies

The iOS/tvOS sample apps support the latest version of the Brightcove Native SDK and plugins.

To add the core Brightcove SDK along with other library dependencies, follow these steps:

  1. If you don't already have CocoaPods, download and install the latest version.
  2. Clone or download the Player samples for iOS/tvOS to your computer.
  3. On your computer, the local sample folder that you are interested in. For this example, we will use the Objective-C version of the VideoCloudBasicPlayer sample.
  4. In a text editor, open the VideoCloudBasicPlayer/objc/Podfile file. Notice that there is no file extension.
  5. In the Podfile, you can leave the iOS platform version, or you can change it to the version you want to target in your app.
    Platform version
    Platform version
  6. Open the project folder in the Terminal app. In the Terminal session, run the pod install command. If you notice that the SDK version is less than the current version, you can run the pod update command to fetch the latest version.
    Run pod install
    Run pod install
  7. In the project folder, you should now see a .xcworkspace file. This is the file you will open in Xcode.

Running the sample apps

The sample apps can be run using the following:

  • Xcode simulator
  • Xcode using a physical device connected to your computer
    • The device must have iOS version 9.0 or later
    • On your device, make sure USB debugging is enabled

To run a sample app, follow these steps:

  1. If you are new to Xcode, review the Apple developer documentation.
  2. In Xcode, open the VideoCloudBasicPlayer.xcworkspace file.
    Project in Xcode
    Project in Xcode
  3. Open the ViewController.m file. You can run the app with the provided values, or you can replace them with your own values. In this sample, you can replace the values for your Video Cloud account ID, video ID and policy key.
    Customize values
    Customize values
  4. In the toolbar's active scheme menu, VideoCloudBasicPlayer project should be selected.
    Project selection
    Project selection
  5. Expand the run destination dropdown. If you have a device connected to your computer, you should see it listed here. Select your device or a simulator version.
    Select device or simulator version
    Select device or simulator version
  6. Select the Run button.
    Run the project
    Run the project
  7. You should see the app running on your device or in the simulator.
    Xcode simulator
    Xcode simulator

Debugging

Xcode provides debugging tools that allow you to set breakpoints, examine variables and evaluate expressions at runtime. To debug your app, do the following:

  1. In Xcode, locate the line of code where you would like to pause execution.
  2. In the left gutter for the line of code, click to add a breakpoint. Double click to edit a breakpoint. Right clicking on the breakpoint gives you options including deleting a breakpoint.
    Breakpoint
    Breakpoint
  3. Select the Run button to start execution.
    Run the project
    Run the project
  4. When execution pauses at your breakpoint, you will have several options to inspect variables and expressions, as well as stepping through/over/into lines of code.

    Pause execution at breakpoint
    Pause execution at breakpoint