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

Cast 프레임워크는 iOS 14 이상을 지원하며, 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 가져오기

    <ph type="x-smartling-placeholder">
  2. Info.plistNSBonjourServices 추가

    Info.plist에서 NSBonjourServices를 지정하여 다음을 수행합니다. iOS 14에서 로컬 네트워크 검색이 성공할 수 있도록 합니다.

    _googlecast._tcp 및 기기의 서비스로서의 _<your-app-id>._googlecast._tcp 탐색이 제대로 작동하는지 확인할 수 있습니다

    appID는 broadcast receiver ID이며 GCKDiscoveryCriteria

    다음 예시 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&#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 프로젝트 탐색기 (있는 경우 포드 프로젝트 아님) '필요한 경우 모든 항목 복사'를 선택하고 모든 타겟에 추가합니다.
  4. Xcode 타겟의 General 탭에서 GoogleCast.xcframeworkEmbed and Sign를 선택합니다.

static 라이브러리를 설정하는 경우 다음 단계 외에 다음 단계를 따르세요. 이전 단계:

  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. 압축을 푼 디렉터리에서 리소스 폴더를 찾습니다. GoogleCastCoreResources.bundle 드래그, GoogleCastUIResources.bundleMaterialDialogs.bundle GoogleCast.xcframework 옆에 있는 프로젝트로 확인할 수 있습니다 '필요한 경우 모든 항목 복사'를 선택하고 모든 항목에 추가 있습니다

Mac Catalyst 설정

Mac Catalyst를 지원하는 앱의 경우 Cast SDK의 동적 라이브러리를 사용합니다. 수동 설정 절차에 따라 프로젝트에 추가합니다 그런 다음 Mac에서 Cast SDK를 조건부로 제외합니다. 타겟팅을 Apple 문서 정적 라이브러리는 iOS 아키텍처용으로 사전 컴파일되어 링커가 발생함 오류가 발생할 수 있습니다.