iOS용 Cast 애플리케이션 프레임워크 (CAF) 개발을 위한 설정

Cast 프레임워크는 iOS 12 이상을 지원하며 정적 프레임워크와 동적 프레임워크 모두 제공됩니다.

모든 클래스와 메서드에 관한 설명은 Google Cast iOS API 참조를 확인하세요.

최신 세대의 Cast 기기는 iOS용 게스트 모드를 지원하지만 이전 세대 기기는 지원하지 않습니다. 자세한 내용은 게스트 모드 - 지원되는 Cast 기기를 참고하세요.

Xcode 설정

iOS 14

  1. 프로젝트에 Cast iOS SDK 4.7.0 추가

    CocoaPods를 사용하는 경우 pod update를 사용하여 프로젝트에 4.7.0 SDK를 추가합니다.

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

  2. Info.plistNSBonjourServices 추가

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

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

    appID는 receiver ID로, 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.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

다음은 Podfilegoogle-cast-sdk-no-bluetooth CocoaPod를 추가하는 방법의 예입니다.

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

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

이 스니펫에서는 버전 4.7.0과 다음 주요 버전 (major.minor.patch)까지의 버전이 허용됩니다.

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

예를 들어 '~> 1.6.7'에는 1.6.7 이상부터 버전 2.0.0까지의 모든 버전이 포함됩니다.

수동 설정

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

다운로드

아래에서 적절한 라이브러리를 다운로드한 후 설정 단계에 따라 프로젝트에 프레임워크를 추가하세요. 설정 요구사항은 기존 범용 프레임워크의 XCFrameworks와 동일합니다.

앱에 게스트 기능이 필요하지 않거나 iOS 13에 도입된 Bluetooth® 권한을 요구하지 않는 상황에 대해 게스트 모드가 없는 라이브러리가 제공되었습니다. 자세한 내용은 iOS 13 변경사항 문서를 참고하세요.

범용 프레임워크

Cast iOS Sender SDK 4.7.0 라이브러리

게스트 모드가 있는 정적 게스트 모드가 없는 정적 모드

동적 모드를 게스트 모드로 설정 게스트 모드를 사용하지 않는 동적 모드

XCFramework (베타)

Cast iOS SDK는 버전 4.7.1부터 XCFrameworks를 지원하므로 Apple M1 컴퓨터에서 개발하고 M1 iOS 시뮬레이터를 사용하여 디버깅할 수 있습니다.

이 라이브러리는 현재 베타 버전입니다. 문제가 있으면 Cast SDK Issue Tracker에 보고해 주세요.

iOS Sender SDK XCFramework 4.7.1 라이브러리

게스트 모드가 있는 정적 XCFramework 게스트 모드가 없는 정적 XCFramework

게스트 모드가 포함된 동적 XCFramework 게스트 모드가 없는 동적 XCFramework

설정 단계

정적 라이브러리 중 하나를 설치하려면 다음을 실행합니다.

  1. 프로젝트에 적합한 정적 SDK를 다운로드하고 압축을 풉니다.
  2. 최소 버전 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 이상을 추가합니다.
  3. 압축을 푼 .framework 또는 .xcframework를 Xcode 프로젝트 탐색기의 기본 프로젝트로 드래그합니다 (Pod 프로젝트가 있는 경우). '필요한 경우 모든 항목 복사'를 선택하고 모든 대상에 추가합니다.
  4. Xcode 프로젝트에서 빌드 설정 > 기타 링커 플래그-ObjC -lc++ 플래그를 추가합니다.
  5. 프로젝트에서 GoogleCast.framework 또는 GoogleCast.xcframework를 마우스 오른쪽 버튼으로 클릭하고 'Show In Finder'를 선택합니다.
  6. GoogleCastCoreResources.bundleGoogleCastUIResources.bundle를 이전에 추가한 GoogleCast.framework 또는 GoogleCast.xcframework 옆의 프로젝트로 드래그하고 '필요한 경우 모든 항목 복사'를 선택하고 모든 대상에 추가합니다.

동적 라이브러리 중 하나를 설치하려면 다음 단계를 따르세요.

  1. 프로젝트에 적합한 동적 SDK를 다운로드하고 압축을 풉니다.
  2. 동적 GoogleCastSDK 라이브러리를 설정합니다.
    1. 프로젝트에서 CocoaPods를 사용하는 경우:
      1. Podfile을 열고 다음을 삭제합니다.
        pod 'google-cast-sdk'
      2. 프로젝트의 루트 폴더에서 pod install를 실행합니다.
    2. 프로젝트에서 CocoaPods를 사용하지 않는 경우 현재 Google Cast 라이브러리를 삭제합니다.
  3. 압축을 푼 .framework 또는 .xcframework를 Xcode 프로젝트 탐색기의 기본 프로젝트로 드래그합니다 (Pod 프로젝트가 있는 경우). '필요한 경우 모든 항목 복사'를 선택하고 모든 대상에 추가합니다.
  4. Xcode 타겟의 General 탭에서 GoogleCast.framework 또는 GoogleCast.xcframeworkEmbed and Sign를 선택합니다.

Mac Catalyst 설정

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

App Store에 앱 게시

App Store에 앱을 게시하기 전에 셸 스크립트 strip_unused_archs.sh를 실행하여 App Bundle에서 사용되지 않는 아키텍처를 삭제해야 합니다. 이 스크립트는 iOS용 Cast SDK에 있습니다.