Das Cast-Framework unterstützt iOS 13 und höher und ist in statischen und dynamischen Frameworks verfügbar.
Beschreibungen aller Klassen und Methoden finden Sie in der Google Cast iOS API-Referenz.
Xcode-Einrichtung
iOS 14
-
Fügen Sie Ihrem Projekt das Cast iOS SDK 4.8.0 hinzu.
Wenn Sie CocoaPods verwenden, fügen Sie Ihrem Projekt mit
pod update
das SDK 4.8.0 hinzu.Andernfalls können Sie das SDK manuell abrufen.
-
NSBonjourServices
zuInfo.plist
hinzufügenGib
NSBonjourServices
in deinemInfo.plist
an, damit die lokale Netzwerkerkennung unter iOS 14 erfolgreich ist.Du musst sowohl
_googlecast._tcp
als auch_<your-app-id>._googlecast._tcp
als Dienste hinzufügen, damit die Geräteerkennung ordnungsgemäß funktioniert.Die appID ist deine ReceiverID, also dieselbe ID, die in
GCKDiscoveryCriteria
definiert ist.Aktualisieren Sie die folgende
NSBonjourServices
-Beispieldefinition und ersetzen Sie „ABCD1234“ durch Ihre Anwendungs-ID. -
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
Hier ist ein Beispiel dafür, wie du den CocoaPod google-cast-sdk-no-bluetooth
zu deinem Podfile
hinzufügst:
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
Für Ihr Projekt sollten Sie einen Bereich für Ihre Pods angeben, um unerwartete Änderungen zu vermeiden. Weitere Informationen finden Sie im Leitfaden zu Pods.
In diesem Snippet sind Version 4.8.0 und die Versionen bis zur nächsten Hauptversion (major.minor.patch) zulässig:
pod 'google-cast-sdk', '~> 4.8.0'
Zum Beispiel würde „~> 1.6.7“ alle Versionen von 1.6.7 bis 2.0.0 einschließen, jedoch nicht einschließlich.
Manuelle Einrichtung
Die folgende Anleitung bezieht sich auf das Hinzufügen des Cast iOS SDK zu Ihrem Projekt ohne CocoaPods:
Downloads
Nachdem Sie unten die entsprechende Bibliothek heruntergeladen haben, führen Sie die Einrichtungsschritte aus, um Ihrem Projekt das Framework hinzuzufügen. Die Einrichtungsanforderungen für XCFrameworks sind mit denen für das alte Universal Frameworks identisch.
Universelles Framework
Cast-Bibliotheken für das Sender SDK 4.8.0 von iOS:
Statisch mit Bluetooth Statisch ohne Bluetooth
Dynamisch mit Bluetooth Dynamisch ohne Bluetooth
XCFramework
Das Cast iOS SDK unterstützt XCFrameworks. Dies ermöglicht die Entwicklung auf Mac-Computern mit Apple Silicon und die Fehlerbehebung mit dem iOS-Simulator.
Streamen von iOS Sender SDK XCFramework 4.8.0-Bibliotheken:
Statisches XCFramework mit Bluetooth Statisches XCFramework ohne Bluetooth
Dynamic XCFramework mit Bluetooth Dynamic XCFramework ohne Bluetooth
Einrichtungsschritte
So installieren Sie eine der static-Bibliotheken:
- Laden Sie das geeignete statische SDK für Ihr Projekt herunter und entpacken Sie es.
- Richten Sie die Protobuf-Bibliothek mit der Mindestversion 3.13 ein.
- Wenn Ihr Projekt CocoaPods verwendet:
-
Öffne
Podfile
und entferne dasgoogle-cast-sdk
(falls vorhanden):pod 'google-cast-sdk'
-
Fügen Sie die
Protobuf
-Bibliothek hinzu, falls sie nicht vorhanden ist:pod 'Protobuf', '3.13'
-
Führen Sie
pod install
im Stammverzeichnis Ihres Projekts aus. - Wenn CocoaPods für Ihr Projekt nicht verwendet wird:
-
Entfernen Sie die aktuelle Version von
GoogleCastSDK
, falls vorhanden. - Fügen Sie die Protobuf-Bibliothek Version 3.13 oder höher hinzu. Folgen Sie dazu der Anleitung im Protobuf-GitHub-Repository.
-
Ziehen Sie das entpackte
.framework
oder.xcframework
in Ihr Hauptprojekt in der Xcode-Projektnavigation (nicht in das Pod-Projekt, falls vorhanden). Aktivieren Sie die Option „Bei Bedarf alle Elemente kopieren“ und fügen Sie sie allen Zielen hinzu. -
Fügen Sie in Ihrem Xcode-Projekt unter Build Settings > Other Linker Flags die Flags
-ObjC -lc++
hinzu. -
Klicken Sie mit der rechten Maustaste auf
GoogleCast.framework
oderGoogleCast.xcframework
in Ihrem Projekt und wählen Sie „In Finder anzeigen“ aus. -
Ziehen Sie
GoogleCastCoreResources.bundle
undGoogleCastUIResources.bundle
in Ihr Projekt neben den zuvor hinzugefügtenGoogleCast.framework
oderGoogleCast.xcframework
, aktivieren Sie „Bei Bedarf alle Elemente kopieren“ und fügen Sie sie allen Zielen hinzu.
So installieren Sie eine der dynamischen Bibliotheken:
- Laden Sie das geeignete dynamische SDK für Ihr Projekt herunter und entpacken Sie es.
- Richten Sie die dynamische GoogleCastSDK-Bibliothek ein:
- Wenn Ihr Projekt CocoaPods verwendet:
-
Öffne dein
Podfile
und entferne Folgendes:pod 'google-cast-sdk'
-
Führen Sie
pod install
im Stammverzeichnis Ihres Projekts aus. - Wenn CocoaPods in deinem Projekt nicht verwendet werden, entferne die aktuelle Google Cast-Bibliothek.
-
Ziehen Sie das entpackte
.framework
oder.xcframework
in Ihr Hauptprojekt in der Xcode-Projektnavigation (nicht in das Pod-Projekt, falls vorhanden). Aktivieren Sie die Option „Bei Bedarf alle Elemente kopieren“ und fügen Sie sie allen Zielen hinzu. -
Wählen Sie in Ihrem Xcode-Ziel auf dem Tab
General
die OptionEmbed and Sign
fürGoogleCast.framework
oderGoogleCast.xcframework
aus.
Einrichtung von Mac Catalyst
Verwenden Sie für Apps, die Mac Catalyst unterstützen, die dynamische Bibliothek des Cast SDK. Folgen Sie dem manuellen Einrichtungsprozess, um Ihrem Projekt das Framework hinzuzufügen. Schließen Sie dann das Cast SDK vom Mac-Ziel aus, wie in der Apple-Dokumentation beschrieben. Statische Bibliotheken werden für die iOS-Architektur vorkompiliert. Dies führt bei der Erstellung für das Mac-Ziel zu einem Verknüpfungsfehler.
App im App Store veröffentlichen
Bevor Sie Ihre Anwendung im App Store veröffentlichen, müssen Sie das Shell-Skript strip_unused_archs.sh
ausführen, um nicht verwendete Architekturen aus dem App Bundle zu entfernen. Dieses Skript befindet sich im Cast SDK for iOS.