Setup

Requirements

The PRESTOPlay SDK for Apple is delivered as XCFramwork and with CocoaPods repository that can be added to your application build. All required dependencies are either:

  • Contained in the bundle repository
  • Available on a public repository like CocoaPods

To work with the PRESTOPlay SDK for Apple you need to use the Xcode for your application builds.

License

Create License Keys tied to your application bundle on https://downloads.castlabs.com

The license model allows activating additional plugins and change the expiration date of the license remotely. This will help to avoid issues when the license runs out and you can not quickly re-deploy your Application.

In our download portal you go to the license you need and select Manage keys: As you do not have any keys assosiated with the license, you will be shown this message: Please select Create a key. After this you are taken to this screen:

Project Setup

  1. Unzip the installation bundle

  2. Add PRESTOPlay.xcframework file to your project “Frameworks, Libraries, and Embedded Content”. Choose “Embed & Sign” as the “Embed Option”

  3. (Optional) Repeat step (2) for any additional plugin frameworks

Initialization

Pass the license string and the list of plugins you want to activate to the register() method

import CastlabsApple

let license = "..."
PRESTOPlay.shared.register(license, [CastlabsApple()])

In some cases (depending on the agreed licensing model), you also need to pass a user ID.

PRESTOPlay.shared.register(license, [], userId)

It’s your app responsibility to set the correct category for AVAudioSession. If your app does only playback AVAudioSessionCategory.playback is sufficient, if your app does playback and record you would need AVAudioSessionCategory.playAndRecord. You only need to do it once per app lifetime.

let audioSession = AVAudioSession.sharedInstance()
do {
    try audioSession.setCategory(.playback)
    try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
} catch {
    log_e("Cannot initialize audio session")
}

SDK assumptions

  1. Minimal supported iOS version is set to 12.
  2. Frameworks in SDK are built as dynamic frameworks.

Test Projects

Included in main package examples/ directory.

  1. examples

Simple demo examples that test the building of core features and plugin integrations. They meant to work without any user interaction and with a very simple UI limited to bare minimum.

Examples are built with UIKit.

  1. examples/Demos

More complicated demo (all-in-one app) with specialized examples and use-cases. For instance: if you want to present / test WebVTT subtitles it is fine to create a Demo for that use-case.

Demos application is built with SwiftUI.

Crash Reports

If a crash occurs when using our release builds, you will see that part of the stack trace is obfuscated due to security reasons. However there’s still a way to re-symbolicate the crash if you send us the load address of our libraries at crash time.

Crash dumps retrieved directly from the device

If the crash dump is retrieved directly from the device via XCode (Window → Devices → View Device Logs), all the info we need is in the crash log itself:

  • Architecture: Check if ARM or ARM-64 in the Code Type line

  • Load address: Either check in the Binary Images, or directly from the stack line (the load address in the line “0 CastlabsDASH 0x00460b8a 0x2be000 + 1715082” is 0x2be000)

Crash dumps retrieved via Crashlytics

Crashlytics doesn’t let you know the load address of the binaries, but it still reports the actual address in memory of a symbol, not the offset from the load address, in its stack traces. You need to attach information about the load addresses to the crash dump via Crashlytics Key-Value system.

Get load addresses and pass them to Crashlytics

var index: UInt32 = 0
while index < _dyld_image_count() {
    let header = _dyld_get_image_header(index)
    if let name = String(validatingUTF8: _dyld_get_image_name(index)), name.contains("Castlabs") {
        header.debugDescription
        break
    }
    index += 1
}

Retrieve them from Crashlytics web UI: select a crash then choose “View All Sessions”. Download the stack trace and txt and copy the pseudo-json with the load addresses for the “CASTLABS LOAD ADDRESSES” key in the “Keys” section.

The Crashlytics stack trace does not specify the CPU architecture, but it contains the device type so you can match it up by looking at the device specs.

CocoaPods

Our SDK can be included and setup via CocoaPods.

The following frameworks are supported on iOS: PRESTOPlay, CastlabsApple, CastlabsDownloader, CastlabsChromecast, CastlabsYoubora, CastlabsSubtitles, CastlabsThumbnails.

The following frameworks are supported on tvOS: PRESTOPlay, CastlabsApple, CastlabsYoubora, CastlabsSubtitles, CastlabsThumbnails.

Access to Cocoapods is public for v4. Please check examples to see pods integrations.

CocoaPods version required is >= 1.10.0. The SDK consists of Dynamic Frameworks.