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

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 the google-cast-sdk CocoaPods or the google-cast-sdk-no-bluetooth CocoaPods if your app does not require the 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 is an example of the google-cast-sdk Cocoapod in a 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 is an example of the google-cast-sdk-no-bluetooth Cocoapod in a 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 example, version 4.7.0 and the versions up to 5.0 are allowed, not including 5.0 and higher:

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

Manual setup

The following instructions are for manually adding the framework to your project.

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 have been introduced in iOS 13. Please see the iOS 13 Changes document for more information.

Download the Cast 4.7.0 iOS Sender API libraries:

Static with Guest Mode Static without Guest Mode

Dynamic with Guest Mode Dynamic without Guest Mode

Right-click GoogleCast.framework in your project, and select Show In Finder.

Drag the GoogleCastCoreResources.bundle and GoogleCastUIResources.bundle into the top-level directory of your Xcode project. When prompted, ensure Copy items into destination group's folder is NOT selected.

In your Xcode project, set the Other Linker Flags in Build Settings to: -ObjC -lc++.

In your Xcode project, open the Build Phases tab for your application’s target, add the following frameworks within Link Binary with Libraries:

  • Accelerate.framework
  • AudioToolbox.framework
  • AVFoundation.framework
  • CFNetwork.framework
  • CoreBluetooth.framework
  • CoreData.framework
  • CoreGraphics.framework
  • CoreMedia.framework
  • CoreText.framework
  • Foundation.framework
  • GoogleCast.framework
  • MediaAccessibility.framework
  • MediaPlayer.framework
  • QuartzCore.framework
  • Security.framework
  • SystemConfiguration.framework
  • UIKit.framework

The libraries appear in your project as follows:

Next, add the GoogleCast.framework to Frameworks, Libraries, and Embedded Content section of the General tab. Keep the embed option as "Do Not Embed" for static framework and "Embed & Sign" for dynamic framework.

Ensure that the Runpath Search Paths setting of the Build Settings in the project's settings is set to "@executable_path/Frameworks".

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.