Why can't I retrieve the groups from the default container of Apple iOS Contacts Framework?

I wonder why they don't have a forum for the Contacts Framework?


I have an iOS app that accesses the default container of the contact store and retrieves the groups within that container. After I signed out of my iPhone 8 device that the app is installed in, and then signed in with another account. Then signed out and signed in with my original account, the app was no longer able to retrieve the groups from the default container.


Why is it doing this and how do I fix this?


Here is the relevant code:


    cnGroups = try contactStore.groups(matching: CNGroup.predicateForGroupsInContainer(withIdentifier: contactStore.defaultContainerIdentifier()))
   
    print("cnGroups...")
    print(cnGroups)


Here is the debug window output:


cnGroups...

[]