iOS용 Cast 애플리케이션 프레임워크 (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를 추가합니다.

    그렇지 않으면 SDK를 수동으로 가져옵니다.

  2. Info.plistNSBonjourServices 추가

    iOS 14에서 로컬 네트워크 검색이 성공할 수 있도록 Info.plistNSBonjourServices를 지정합니다.

    기기 검색이 제대로 작동하려면 _googlecast._tcp_<your-app-id>._googlecast._tcp를 모두 서비스로 추가해야 합니다.

    appID는 receiverID로, GCKDiscoveryCriteria에 정의된 것과 동일한 ID입니다.

    다음 예시 NSBonjourServices 정의를 업데이트하고 'ABCD1234'를 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.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

프로젝트의 경우 podfile 가이드에 설명된 대로 예기치 않은 브레이킹 체인지를 방지하기 위해 포드의 범위를 지정해야 합니다.

이 스니펫에서는 버전 4.8.1 및 다음 주 버전 (major.minor.patch)의 버전이 허용됩니다.

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

예를 들어 '~> 1.6.7'에는 버전 2.0.0을 제외한 1.6.7 이상의 모든 버전이 포함됩니다.

수동 설정

다음은 CocoaPods를 사용하지 않고 프로젝트에 Cast iOS SDK를 추가하는 방법입니다.

다운로드

아래에서 적절한 라이브러리를 다운로드한 후 설정 단계에 따라 프로젝트에 프레임워크를 추가하세요.

Cast iOS Sender SDK 4.8.1 라이브러리:

정적 동적

설정 단계

라이브러리를 설치하려면 다음 안내를 따르세요.

  1. 프로젝트에 적합한 SDK를 다운로드하고 압축을 풉니다.
  2. 동적 GoogleCastSDK 라이브러리를 설정합니다.
  3. 압축을 푼 .xcframework를 Xcode 프로젝트 탐색기에서 기본 프로젝트로 드래그합니다 (포드 프로젝트가 있는 경우 해당 프로젝트 제외). '필요한 경우 모든 항목 복사'를 선택하고 모든 대상에 추가합니다.
  4. Xcode 대상의 General 탭에서 GoogleCast.xcframeworkEmbed and Sign를 선택합니다.

정적 라이브러리를 설정하는 경우 이전 단계 외에 다음 단계도 수행합니다.

  1. 최소 버전 v3.13으로 Protobuf 라이브러리를 설정합니다.
    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 GitHub 저장소의 안내에 따라 Protobuf 라이브러리 v3.13 이상을 추가합니다.
  2. Xcode 프로젝트에서 -ObjC -lc++ 플래그를 Build Settings > Other Linker Flags에 추가합니다.
  3. 압축을 푼 디렉터리에서 Resources 폴더를 찾아 GoogleCastCoreResources.bundle, GoogleCastUIResources.bundle, MaterialDialogs.bundle를 이전에 추가한 GoogleCast.xcframework 옆의 프로젝트로 드래그합니다. 'Copy all items if needed'(필요한 경우 모든 항목 복사)를 선택하고 모든 타겟에 추가합니다.

Mac Catalyst 설정

Mac Catalyst를 지원하는 앱의 경우 Cast SDK의 동적 라이브러리를 사용합니다. 수동 설정 프로세스에 따라 프로젝트에 프레임워크를 추가합니다. 그런 다음 Apple 문서에 설명된 대로 Mac 대상에서 Cast SDK를 조건부로 제외합니다. 정적 라이브러리는 iOS 아키텍처에 대해 사전 컴파일되므로 Mac 타겟을 대상으로 빌드할 때 링커 오류가 발생합니다.