Setup for Developing With the Cast Application Framework (CAF) for iOS

Stay organized with collections Save and categorize content based on your preferences.

The Cast framework supports iOS 12 and later, and comes in both static and dynamic frameworks.

See the Google Cast iOS API Reference for descriptions of all classes and methods.

Note that newer generation Cast devices support guest mode for iOS but older generation devices do not. For details, see Guest Mode - Supported Cast Devices.

Xcode setup

iOS 14

  1. Add the Cast iOS SDK 4.7.0 to your project

    If using CocoaPods, use pod update to add the 4.7.0 SDK to your project.

    Otherwise, pull in the SDK manually.

  2. Add NSBonjourServices to your Info.plist

    Specify NSBonjourServices in your Info.plist to allow local network discovery to succeed on iOS 14.

    You will need to add both _googlecast._tcp and _<your-app-id>._googlecast._tcp as services for device discovery to work properly.

    The appID is your receiverID, which is the same ID that is defined in your GCKDiscoveryCriteria.

    Update the following example NSBonjourServices definition and replace "ABCD1234" with your appID.

    <key>NSBonjourServices</key>
    <array>
      <string>_googlecast._tcp</string>
      <string>_ABCD1234._googlecast._tcp</string>
    </array>
  3. Add NSLocalNetworkUsageDescription to your Info.plist

    We strongly recommend that you customize the message shown in the Local Network prompt by adding an app-specific permission string in your app's Info.plist file for the NSLocalNetworkUsageDescription such as to describe Cast discovery and other discovery services, like DIAL.

    <key>NSLocalNetworkUsageDescription</key>
    <string>${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi
    network.</string>

    This message will appear as part of the iOS Local Network Access dialog as shown in the mock.

    Cast Local Network Access permissions dialog image
  4. Re-release your app to the Apple App Store

    We recommend you also re-release your app using 4.7.0 as soon as possible.

iOS 13

iOS 12

Ensure that the Access WiFi Information switch in the Capabilities section of the target is set to "On".

Additionally, your provisioning profile will need to support the Access WiFi Information capability. This can be added in the Apple Developer Portal.

CocoaPods setup

The recommended way of integrating Google Cast is using CocoaPods.

The google-cast-sdk and google-cast-sdk-no-bluetooth CocoaPods are available for download.

Use the google-cast-sdk-no-bluetooth if your app does not require guest mode or you do not wish to require Bluetooth® permission.

To get started, follow the getting started guide.

Once CocoaPods is set up, follow the using CocoaPods guide to get your Podfile created and your project ready to use with the Google Cast SDK.

Here's an example of how to add the google-cast-sdk CocoaPod to your Podfile:

use_frameworks!

platform :ios, '12.0'

def target_pods
  pod 'google-cast-sdk'
end

target 'CastVideos-objc' do
  target_pods
end
target 'CastVideos-swift' do
  target_pods
end

Here's an example of how to add the google-cast-sdk-no-bluetooth CocoaPod to your Podfile:

use_frameworks!

platform :ios, '12.0'

def target_pods
  pod 'google-cast-sdk-no-bluetooth'
end

target 'CastVideos-objc' do
  target_pods
end
target 'CastVideos-swift' do
  target_pods
end

For your project, you should specify a range for your pods to prevent unexpected breaking changes as detailed in the podfile guide.

In this snippet, version 4.7.0 and the versions up to the next major version (major.minor.patch) are allowed:

pod 'google-cast-sdk', '~> 4.7.0'

For example, '~> 1.6.7' would include all versions from 1.6.7 and up to, but not including, version 2.0.0.

Manual setup

The following instructions are for adding the Cast iOS SDK to your project without using CocoaPods:

Downloads

After downloading the appropriate library below, follow the setup steps to add the framework to your project. The setup requirements are the same for XCFrameworks as the legacy Universal Frameworks.

Libraries without guest mode have been provided for situations where your app does not require the feature or you do not wish to require Bluetooth® permissions, which were introduced in iOS 13. Please see the iOS 13 Changes document for more information.

Universal Framework

Cast iOS Sender SDK 4.7.0 libraries:

Static with Guest Mode Static without Guest Mode

Dynamic with Guest Mode Dynamic without Guest Mode

XCFramework (Beta)

Beginning with version 4.7.1, the Cast iOS SDK supports XCFrameworks, allowing for development on Apple M1 computers and debugging using the M1 iOS Simulator.

These libraries are currently in Beta. Please report any issues to the Cast SDK Issue Tracker.

Cast iOS Sender SDK XCFramework 4.7.1 libraries:

Static XCFramework with Guest Mode Static XCFramework without Guest Mode

Dynamic XCFramework with Guest Mode Dynamic XCFramework without Guest Mode

Setup steps

To install one of the static libraries:

  1. Download and unzip the appropriate static SDK for your project.
  2. Set up the Protobuf library with minimum version v3.13.
    1. If your project uses CocoaPods:
      1. Open your Podfile and remove the google-cast-sdk if present:
        pod 'google-cast-sdk'
      2. Add the Protobuf library if not present:
        pod 'Protobuf', '3.13'
      3. Run pod install in the root folder of your project.
    2. If your project is not using CocoaPods:
      1. Remove the current version of GoogleCastSDK if present.
      2. Add the Protobuf library v3.13 or greater, following the instructions found on the Protobuf GitHub repo.
  3. Drag the unzipped .framework or .xcframework into your main project in the Xcode project navigator (not into the Pods project if you have one). Check 'Copy all items if needed', and add to all targets.
  4. In your Xcode project, add the flags -ObjC -lc++ to Build Settings > Other Linker Flags.
  5. Right-click GoogleCast.framework or GoogleCast.xcframework in your project, and select 'Show In Finder'.
  6. Drag the GoogleCastCoreResources.bundle and GoogleCastUIResources.bundle into the your project next to the GoogleCast.framework or GoogleCast.xcframework you added previously and check 'Copy all items if needed', and add to all targets.

To install one of the dynamic libraries:

  1. Download and unzip the appropriate dynamic SDK for your project.
  2. Set up the dynamic GoogleCastSDK library:
    1. If your project uses CocoaPods:
      1. Open your Podfile and remove:
        pod 'google-cast-sdk'
      2. Run pod install in the root folder of your project.
    2. If your project is not using CocoaPods, remove the current Google Cast library.
  3. Drag the unzipped .framework or .xcframework into your main project in the Xcode project navigator (not into the Pods project if you have one). Check 'Copy all items if needed', and add to all targets.
  4. In your Xcode target, under the General tab, select Embed and Sign for GoogleCast.framework or GoogleCast.xcframework.

Mac Catalyst setup

For Apps that support Mac Catalyst, use the dynamic library of the Cast SDK. Follow the manual setup process to add the framework to your project. Then conditionally exclude the Cast SDK from the Mac target as mentioned in the Apple documentation. Static libraries are pre-compiled for iOS architecture, which causes a linker error when building against the Mac target.

Publishing your app to App Store

Before publishing your app to the App Store, you need to run shell script strip_unused_archs.sh to strip unused architectures from the app bundle. This script is in the Cast SDK for iOS.