Cast 프레임워크는 iOS 13 이상을 지원하며 정적 프레임워크와 동적 프레임워크로 모두 제공됩니다.
모든 클래스와 메서드에 대한 설명은 Google Cast iOS API 참조를 확인하세요.
Xcode 설정
iOS 14
-
프로젝트에 Cast iOS SDK 4.8.0 추가
CocoaPods를 사용하는 경우
pod update
를 사용하여 프로젝트에 4.8.0 SDK를 추가합니다.그렇지 않으면 SDK를 수동으로 가져옵니다.
-
Info.plist
에NSBonjourServices
추가iOS 14에서 로컬 네트워크 검색이 성공할 수 있도록
Info.plist
에NSBonjourServices
를 지정합니다.기기 검색이 제대로 작동하려면
_googlecast._tcp
와_<your-app-id>._googlecast._tcp
를 모두 서비스로 추가해야 합니다.appID는 receiverID로,
GCKDiscoveryCriteria
에 정의된 것과 동일한 ID입니다.다음 예시
NSBonjourServices
정의를 업데이트하고 'ABCD1234'를 appID로 바꿉니다. -
Add
NSLocalNetworkUsageDescription
to yourInfo.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 theNSLocalNetworkUsageDescription
such as to describe Cast discovery and other discovery services, like DIAL.This message will appear as part of the iOS Local Network Access dialog as shown in the mock.
-
Re-release your app to the Apple App Store
We recommend you also re-release your app using 4.8.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. CocoaPods is supported for both the Universal Framework and XCFramework.
For a Universal Framework integration, use the
google-cast-sdk
and
google-cast-sdk-no-bluetooth
CocoaPods.
For an XCFramework integration, use the google-cast-sdk-xcframework
and
google-cast-sdk-no-bluetooth-xcframework
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, '13.0'
def target_pods
pod 'google-cast-sdk'
end
target 'CastVideos-objc' do
target_pods
end
target 'CastVideos-swift' do
target_pods
end
다음은 Podfile
에 google-cast-sdk-no-bluetooth
CocoaPod를 추가하는 방법의 예입니다.
use_frameworks!
platform :ios, '13.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.8.0과 다음 주 버전 (major.minor.patch)의 버전이 허용됩니다.
pod 'google-cast-sdk', '~> 4.8.0'
예를 들어 '~> 1.6.7'에는 버전 2.0.0을 제외한 1.6.7 이상의 모든 버전이 포함됩니다.
수동 설정
다음은 CocoaPods를 사용하지 않고 프로젝트에 Cast iOS SDK를 추가하는 방법입니다.
오프라인 저장 콘텐츠
아래에서 적절한 라이브러리를 다운로드한 후 설정 단계에 따라 프로젝트에 프레임워크를 추가하세요. XCFrameworks의 설정 요구사항은 기존 범용 프레임워크와 동일합니다.
범용 프레임워크
Cast iOS Sender SDK 4.8.0 라이브러리:
블루투스를 사용한 정적 블루투스를 사용하지 않은 경우의 정적
블루투스를 통한 동적 블루투스를 사용하지 않은 경우 동적
XCFramework
Cast iOS SDK는 XCFrameworks를 지원하므로 Apple silicon을 사용하는 Mac 컴퓨터에서 개발 및 iOS 시뮬레이터를 사용한 디버깅이 가능합니다.
Cast iOS Sender SDK XCFramework 4.8.0 라이브러리:
블루투스를 사용하는 정적 XCFramework 블루투스를 사용하지 않는 정적 XCFramework
블루투스를 사용하는 동적 XCFramework 블루투스를 사용하지 않는 동적 XCFramework
설정 단계
정적 라이브러리 중 하나를 설치하려면 다음 안내를 따르세요.
- 프로젝트에 적합한 정적 SDK를 다운로드하고 압축을 풉니다.
- 최소 버전 v3.13으로 Protobuf 라이브러리를 설정합니다.
- 프로젝트에서 CocoaPods를 사용하는 경우:
-
Podfile
를 열고google-cast-sdk
가 있는 경우 삭제합니다.pod 'google-cast-sdk'
-
Protobuf
라이브러리가 없으면 추가합니다.pod 'Protobuf', '3.13'
-
프로젝트의 루트 폴더에서
pod install
를 실행합니다. - 프로젝트에서 CocoaPods를 사용하지 않는 경우:
-
GoogleCastSDK
의 현재 버전이 있으면 삭제합니다. - Protobuf GitHub 저장소의 안내에 따라 Protobuf 라이브러리 v3.13 이상을 추가합니다.
-
압축을 푼
.framework
또는.xcframework
를 Xcode 프로젝트 탐색기에서 기본 프로젝트로 드래그합니다 (포드 프로젝트가 있는 경우 해당 프로젝트 제외). '필요한 경우 모든 항목 복사'를 선택하고 모든 대상에 추가합니다. -
Xcode 프로젝트에서
-ObjC -lc++
플래그를 Build Settings > Other Linker Flags에 추가합니다. -
프로젝트에서
GoogleCast.framework
또는GoogleCast.xcframework
를 마우스 오른쪽 버튼으로 클릭하고 'Finder에 표시'를 선택합니다. -
이전에 추가한
GoogleCast.framework
또는GoogleCast.xcframework
옆의 프로젝트로GoogleCastCoreResources.bundle
및GoogleCastUIResources.bundle
를 드래그하고 'Copy all items if needed'(필요한 경우 모든 항목 복사)를 선택한 다음 모든 대상에 추가합니다.
동적 라이브러리 중 하나를 설치하려면 다음 안내를 따르세요.
- 프로젝트에 적합한 동적 SDK를 다운로드하고 압축을 풉니다.
- 동적 GoogleCastSDK 라이브러리를 설정합니다.
- 프로젝트에서 CocoaPods를 사용하는 경우:
-
Podfile
을 열고 다음을 삭제합니다.pod 'google-cast-sdk'
-
프로젝트의 루트 폴더에서
pod install
를 실행합니다. - 프로젝트에서 CocoaPods를 사용하지 않는 경우 현재 Google Cast 라이브러리를 삭제합니다.
-
압축을 푼
.framework
또는.xcframework
를 Xcode 프로젝트 탐색기에서 기본 프로젝트로 드래그합니다 (포드 프로젝트가 있는 경우 해당 프로젝트 제외). '필요한 경우 모든 항목 복사'를 선택하고 모든 대상에 추가합니다. -
Xcode 타겟의
General
탭에서GoogleCast.framework
또는GoogleCast.xcframework
에Embed and Sign
를 선택합니다.
Mac Catalyst 설정
Mac Catalyst를 지원하는 앱의 경우 Cast SDK의 동적 라이브러리를 사용합니다. 수동 설정 프로세스에 따라 프로젝트에 프레임워크를 추가합니다. 그런 다음 Apple 문서에 설명된 대로 Mac 대상에서 Cast SDK를 조건부로 제외합니다. 정적 라이브러리는 iOS 아키텍처에 대해 사전 컴파일되므로 Mac 타겟을 대상으로 빌드할 때 링커 오류가 발생합니다.
App Store에 앱 게시
앱을 App Store에 게시하기 전에 셸 스크립트 strip_unused_archs.sh
를 실행하여 사용되지 않는 아키텍처를 App Bundle에서 삭제해야 합니다. 이 스크립트는 iOS용 Cast SDK에 있습니다.