iOS 用 Cast Application Framework(CAF)を使用した開発のセットアップ

Cast フレームワークは iOS 14 以降をサポートし、 静的フレームワークと動的フレームワークです

詳しくは、Google Cast iOS API リファレンスをご覧ください。 すべてのクラスとメソッドの説明です。

Xcode の設定

iOS 14

  1. Cast iOS SDK 4.8.1 をプロジェクトに追加する

    CocoaPods を使用している場合は、pod update を使用して 4.8.1 SDK をプロジェクトに追加します。

    それ以外の場合は <ph type="x-smartling-placeholder"></ph> SDK を手動で pull することもできます

    <ph type="x-smartling-placeholder">
  2. NSBonjourServicesInfo.plist に追加する

    Info.plistNSBonjourServices を指定して、 iOS 14 でのローカル ネットワークの検出が可能になりました。

    _googlecast._tcp と デバイスのサービスとしての_<your-app-id>._googlecast._tcp 確認します。

    appID は receiverID です。これは、 GCKDiscoveryCriteria

    次の NSBonjourServices 定義の例を更新します。 「ABCD1234」に置き換えるをアプリ ID に置き換えます。

    <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.8.1 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. For integration, use the google-cast-sdk CocoaPods.

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, '14.0'

def target_pods
  pod 'google-cast-sdk'
end

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

プロジェクトで Pod の範囲を指定することで、予期しない 記載されている互換性を破る変更については、 podfile ガイドをご覧ください。

このスニペットでは、バージョン 4.8.1 とそれ以後のバージョン 使用できるメジャー バージョン(major.minor.patch)は次のとおりです。

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

例: '~>1.6.7&#39;1.6.7 とそれ以前のすべてのバージョンが含まれますが、 バージョン 2.0.0 を含む。

手動セットアップ

プロジェクトに Cast iOS SDK を追加する手順は次のとおりです。 CocoaPods を使わない場合:

ダウンロード

以下の適切なライブラリをダウンロードしたら、 設定手順に沿って、フレームワークを できます。

Cast iOS Sender SDK 4.8.1 ライブラリ:

静的 動的

設定の手順

ライブラリをインストールするには:

  1. プロジェクトに適した SDK をダウンロードして展開します。
  2. 動的な GoogleCastSDK ライブラリをセットアップします。
  3. 解凍した .xcframework を Xcode プロジェクト ナビゲータ(Pod プロジェクトが存在する場合は Pod プロジェクトに移動しない)。 [必要に応じてすべてのアイテムをコピーする] チェックボックスをオンにして、すべてのターゲットに追加します。
  4. Xcode ターゲットの General タブで、GoogleCast.xcframeworkEmbed and Sign を選択します。

静的ライブラリを設定する場合は、次の手順に加えて、 確認します。

  1. 最小バージョンで Protobuf ライブラリを設定する バージョン 3.13 でリリースされました。
    1. プロジェクトで CocoaPods を使用している場合:
      1. Podfile を開き、 google-cast-sdk(存在する場合):
        pod 'google-cast-sdk'
      2. Protobuf ライブラリが存在しない場合は追加します。
        pod 'Protobuf', '3.13'
      3. プロジェクトのルートフォルダで pod install を実行します。
    2. プロジェクトで CocoaPods を使用していない場合:
      1. GoogleCastSDK の現在のバージョンを削除します(存在する場合)。
      2. Protobuf ライブラリ v3.13 以降を追加する。 記載されている手順に沿って Protobuf(GitHub) リポジトリをご覧ください
  2. Xcode プロジェクトで、フラグ -ObjC -lc++ を以下に追加します。 ビルド設定 >その他のリンカーフラグ
  3. 解凍したディレクトリで Resources フォルダを見つけて、 GoogleCastCoreResources.bundle をドラッグ、 GoogleCastUIResources.bundle さんと MaterialDialogs.bundle さん 「GoogleCast.xcframework」の横のプロジェクトに 追加します。[必要に応じてすべてのアイテムをコピーする] チェックボックスをオンにして、すべてに追加する できます。

Mac の Catalyst の設定

Mac Catalyst をサポートするアプリの場合は、Cast SDK の動的ライブラリを使用します。 手動セットアップの手順に沿って、 フレームワークをプロジェクトに追加します。条件付きで Mac から Cast SDK を除外する 記載されているとおりに Apple のドキュメント 静的ライブラリが iOS アーキテクチャ用にプリコンパイルされるため、リンカーが発生する エラーが発生することがあります。