Nelly v
Nelly v

Reputation: 239

User Defaults couldn't read values in CFPrefsPlistSource

I have a messaging app where I use an app extension to be able to look up contact information when I receive an APN containing a new message. I exchange the Addressbook contacts info which I have saved in my app through app groups with the help of NSUserDefaults.

Recently I keep getting the below error:

[User Defaults] Couldn't read values in CFPrefsPlistSource (Domain: group.com.xxxx.xxxx, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd

This sometimes returns empty NSUserDefaults throughout my app and makes the app behave as a first time use. I have looked at other link, especificly this one: Failed to read values in CFPrefsPlistSource iOS 10

None of the suggested solutions solved my problem. Anyone knows how I should proceed with this?

Upvotes: 7

Views: 3313

Answers (1)

carlynorama
carlynorama

Reputation: 324

I added this answer to a similar question: Failed to read values in CFPrefsPlistSource iOS 10

There are other things to try there.

My issue ended up being I didn't realize your MacOS AppGroups and iOS AppGroups must live on separate targets. MacOS needs the ID to have that MYTEAMID right at the beginning and iOS needs group.. Xcode 15 autocorrects the number leading appgroup ids to group. leading appgroup ids if iOS anything is on the target at all. You can't just #if os(macOS) in your code to pick which one you want, they must be separate targets with separate entitlement files.

Upvotes: 0

Related Questions