Initialize NSPersistentCloudKitContainer with iOS 14 and Public DB

I'm struggling to initialize my schema. I keep getting the error :

Code Block
Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={NSLocalizedFailureReason=Couldn't initialize CloudKit schema because no stores in the coordinator are configured to use CloudKit


Without the initialize it does sometimes create the record's schema. But it feels like its all half working. I have Cloudkit on and Used with Cloudkit is checked under the default configuration in my xcdatamodeld file.

Here is my setup code..

Code Block
_persistentContainer = [[NSPersistentCloudKitContainer alloc] initWithName:@"Eco-nomy"];
// Add options and make this container PUBLIC.
NSPersistentStoreDescription *description = _persistentContainer.persistentStoreDescriptions.firstObject;
[description setOption:[NSNumber numberWithBool:YES] forKey:NSPersistentHistoryTrackingKey];
[description setOption:[NSNumber numberWithBool:YES] forKey:NSPersistentStoreRemoteChangeNotificationPostOptionKey];
description.cloudKitContainerOptions.databaseScope = CKDatabaseScopePublic;
[description setCloudKitContainerOptions:[self getCloudKitOptions]];
NSError *error;
if (![_persistentContainer initializeCloudKitSchemaWithOptions:NSPersistentCloudKitContainerSchemaInitializationOptionsPrintSchema error:&error])
{
NSLog (@"***** ERROR Initializing Cloudkit : %@", error);
exit (0);
}


This is a bit of a mixed bag on how to get this setup but I've been tried multiple different paths. The example code does not show the new way of doing this schema initialization.

Appreciate any thoughts here.
Initialize NSPersistentCloudKitContainer with iOS 14 and Public DB
 
 
Q