I am trying to migrate iOS Sender App From Cast SDK v2 to the Cast Application Framework (CAF) following this guide: https://developers.google.com/cast/docs/migrate_v2/ios_sender
iOS version is 14 and I followed instructions on this page: https://developers.google.com/cast/docs/ios_sender/ios_permissions_changes
Here is what I already have done:
Added manually the Cast iOS SDK 4.5.0 (no bluetooth) to my project.
Added NSBonjourServices to my Info.plist where XXXXXXXX is my custom receiver app id:
<key>NSBonjourServices</key>
<array>
<string>_googlecast._tcp</string>
<string>_XXXXXXXX._googlecast._tcp</string>
</array>
Added NSLocalNetworkUsageDescription to my Info.plist.
Added "Access WiFi information" entitlement:
<?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>
My app uses custom UI to select casting device so I don't use GCKUICastButton. Here is my code running in viewDidLoad method of my main UIViewController which is also 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];
Result: GCKDeviceManagerDelegate methods (didStartDiscoveryForDeviceCategory, didInsertDevice, didRemoveDevice) never called. On my debug console I see this message (if it has any connection to my problem):
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
Any help will be highly appreciated!
XCode does not add automatically GoogleCast.framework bundle files to the project and this is the reason for this error.
To correct this you will have to add bundle files manually. To do it go to your project settings "Build Phases" -> "Copy Bundle Resources" -> "Add Items" -> "Add other". Then locate GoogleCastCoreResources.bundle and GoogleCastUIResources.bundle in GoogleCast.framework folder. Select them and add.
This should fix the problem.