无法使用GoogleCastSDK iOS 4.5.0在iOS 14上启动设备发现



我正试图按照本指南将iOS Sender应用程序从Cast SDK v2迁移到Cast应用程序框架(CAF(:https://developers.google.com/cast/docs/migrate_v2/ios_sender

iOS版本是14,我遵循了此页面上的说明:https://developers.google.com/cast/docs/ios_sender/ios_permissions_changes

以下是我已经做过的:

  1. 手动将Cast iOS SDK 4.5.0(无蓝牙(添加到我的项目中。

  2. 将NSBonjourServices添加到我的Info.plist中,其中XXXXXXXX是我的自定义接收器应用程序id:

<key>NSBonjourServices</key>
<array>
<string>_googlecast._tcp</string>
<string>_XXXXXXXX._googlecast._tcp</string>
</array>
  1. 将NSLocalNetworkUsageDescription添加到我的Info.plist.

  2. 添加";接入WiFi信息";权利:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.networking.wifi-info</key>
<true/>
</dict>
</plist>

我的应用程序使用自定义UI来选择选角设备,所以我不使用GCKUICastButton。以下是我在主UIViewController的viewDidLoad方法中运行的代码,该方法也是GCKDiscoveryManagerListener:

[GCKLogger sharedInstance].delegate = self;

GCKDiscoveryCriteria* discoveryCriteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:kMyReceiverAppId];
GCKCastOptions *options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:discoveryCriteria];
options.startDiscoveryAfterFirstTapOnCastButton = NO;
options.disableDiscoveryAutostart = NO;
[GCKCastContext setSharedInstanceWithOptions:options];
GCKDiscoveryManager* chromecastDiscoveryManager = [GCKCastContext sharedInstance].discoveryManager;
[chromecastDiscoveryManager addListener:self];
[chromecastDiscoveryManager startDiscovery];

结果:GCKDeviceManagerDelegate方法(didStartDiscoveryForDeviceCategory、didInsertDevice、didRemoveDevice(从未调用在我的调试控制台上,我看到了以下消息(如果它与我的问题有任何联系(:

CoreData model CastFrameworkDB.momd not found at (null), -[GCKDatabase initWithEmpty:inMemory:runtimeConfiguration:]_block_invoke, GCKDatabase.m:217
Can't initialize database because the model can't be found in bundle, aborting, -[GCKDatabase initWithEmpty:inMemory:runtimeConfiguration:]_block_invoke, GCKDatabase.m:218

如有任何帮助,我们将不胜感激!

XCode不会自动将GoogleCast.framework捆绑文件添加到项目中,这就是导致此错误的原因。

要更正此问题,您必须手动添加捆绑文件。要做到这一点,请转到您的项目设置";构建阶段"->quot;复制捆绑资源"->quot;添加项目"->quot;添加其他";。然后在GoogleCast.framework文件夹中找到GoogleCastCoreResources.bundleGoogle CastUIResources.bundle。选择它们并添加。

这应该可以解决问题。

最新更新