【问题标题】:Unable to start device discovery on iOS 14 using GoogleCastSDK iOS 4.5.0无法使用 GoogleCastSDK iOS 4.5.0 在 iOS 14 上启动设备发现
【发布时间】:2021-01-23 09:58:26
【问题描述】:

我正在尝试按照本指南将 iOS Sender App 从 Cast SDK v2 迁移到 Cast Application Framework (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. 在我的 Info.plist 中添加了 NSLocalNetworkUsageDescription。

  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

任何帮助将不胜感激!

【问题讨论】:

  • 根据报错,你的项目找不到文件CastFrameworkDB.momd。请参阅Apple docs 如何为您的应用设置核心数据..

标签: ios objective-c ios14 google-cast-sdk


【解决方案1】:

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

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

这应该可以解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-16
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-03
    • 2021-04-05
    • 1970-01-01
    相关资源
    最近更新 更多