Das Cast-Framework unterstützt iOS 13 und höher und ist als statisches und dynamisches Framework 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 laden Sie das SDK manuell per Pull.
-
NSBonjourServices
zu IhremInfo.plist
hinzufügenGib
NSBonjourServices
in deinemInfo.plist
an, damit das lokale Netzwerk unter iOS 14 erkannt werden kann.Du musst sowohl
_googlecast._tcp
als auch_<your-app-id>._googlecast._tcp
als Dienste hinzufügen, damit die Geräteerkennung richtig funktioniert.Die appID ist Ihre ReceiverID. Sie ist mit der ID in
GCKDiscoveryCriteria
identisch.Aktualisieren Sie die folgende
NSBonjourServices
-Beispieldefinition und ersetzen Sie „ABCD1234“ durch Ihre 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
Hier ist ein Beispiel dafür, wie Sie den CocoaPod google-cast-sdk-no-bluetooth
zu Ihrem Podfile
hinzufügen:
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
Sie sollten für Ihr Projekt einen Bereich für Ihre Pods angeben, um unerwartete Änderungen zu verhindern. Weitere Informationen finden Sie in der Anleitung zu Pods.
In diesem Snippet sind Version 4.8.0 sowie die Versionen bis zur nächsten Hauptversion (major.minor.patch) zulässig:
pod 'google-cast-sdk', '~> 4.8.0'
Beispiel: "~> 1.6.7" würde alle Versionen von 1.6.7 bis, jedoch nicht einschließlich, Version 2.0.0 einschließen.
Manuelle Einrichtung
So fügen Sie Ihrem Projekt das Cast iOS SDK hinzu, ohne CocoaPods zu verwenden:
Downloads
Nachdem Sie unten die entsprechende Bibliothek heruntergeladen haben, folgen Sie den Einrichtungsschritten, um das Framework Ihrem Projekt hinzuzufügen. Die Einrichtungsanforderungen für XCFrameworks sind dieselben wie für die alten universellen Frameworks.
Universelles Framework
Cast-Bibliotheken für iOS Sender SDK 4.8.0:
Statisch mit Bluetooth Statisch ohne Bluetooth
Dynamisch mit Bluetooth Dynamisch ohne Bluetooth
XCFramework
Das Cast iOS SDK unterstützt XCFrameworks, was die Entwicklung auf Mac-Computern mit Apple Silicon sowie die Fehlerbehebung mit dem iOS-Simulator ermöglicht.
XCFramework 4.8.0-Bibliotheken des iOS Sender SDK übertragen:
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 entsprechende 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:
-
Öffnen Sie
Podfile
und entfernen Siegoogle-cast-sdk
(falls vorhanden):pod 'google-cast-sdk'
-
Fügen Sie die Bibliothek
Protobuf
hinzu, falls sie nicht vorhanden ist:pod 'Protobuf', '3.13'
-
Führen Sie
pod install
im Stammverzeichnis Ihres Projekts aus. - Wenn Ihr Projekt nicht CocoaPods verwendet:
-
Entfernen Sie die aktuelle Version von
GoogleCastSDK
, falls vorhanden. - Fügen Sie die Protobuf-Bibliothek ab Version 3.13 hinzu. Folgen Sie dazu der Anleitung im Protobuf-GitHub-Repository.
-
Ziehen Sie die entpackte Datei
.framework
oder.xcframework
in Ihr Hauptprojekt im Xcode-Projektnavigator (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 „Im Finder anzeigen“ aus. -
Ziehen Sie
GoogleCastCoreResources.bundle
undGoogleCastUIResources.bundle
in das Projekt neben den zuvor hinzugefügtenGoogleCast.framework
oderGoogleCast.xcframework
. Klicken Sie auf das Kästchen neben „Copy all items if needed“ (Alle Elemente bei Bedarf kopieren) und fügen Sie sie allen Zielen hinzu.
So installieren Sie eine der dynamischen Bibliotheken:
- Laden Sie das entsprechende dynamische SDK für Ihr Projekt herunter und entpacken Sie es.
- Richten Sie die dynamische GoogleCastSDK-Bibliothek ein:
- Wenn Ihr Projekt CocoaPods verwendet:
-
Öffnen Sie
Podfile
und entfernen Sie Folgendes:pod 'google-cast-sdk'
-
Führen Sie
pod install
im Stammverzeichnis Ihres Projekts aus. - Wenn dein Projekt nicht CocoaPods verwendet, entferne die aktuelle Google Cast-Bibliothek.
-
Ziehen Sie die entpackte Datei
.framework
oder.xcframework
in Ihr Hauptprojekt im Xcode-Projektnavigator (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.
Mac Catalyst einrichten
Verwende 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 bedingt aus dem Mac-Ziel aus, wie in der Apple-Dokumentation beschrieben. Statische Bibliotheken werden für die iOS-Architektur vorkompiliert, was beim Erstellen für das Mac-Ziel einen Verknüpfungsfehler verursacht.
App im App Store veröffentlichen
Bevor Sie Ihre App 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.