Cannot Access NSUserDefaults in App Group on Device

Hi folks,


I just started building an iMessage app onto one of our iOS 10 beta developer devices, and I've run into an issue when attempting to access NSUserDefaults which are stored in our App Group's shared container.This only occurs when building directly to a device - this doesn't happen when building onto the simulator.


[User Defaults] Failed to read values in CFPrefsPlistSource (Domain: group.com.company.App, User: kCFPreferencesAnyUser, ByHost: Yes, Container: null: Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd


This is with XCode Beta 6 and iOS 10 Beta 8.

Is anyone else experiencing this? I found this one SO post which seems to be what we're running into: http://stackoverflow.com/questions/38275395/failed-to-read-values-in-cfprefsplistsource-ios-10

+1


I'm running Xcode 8 Beta 6 and iOS 10 Beta 8 and have the application group properly set on both iOS container app and notification container extension. The app is built and signed properly.


Running the app on device results in the following error when I try to either read or write to a NSUserDefaults instance instantiated with initWithSuiteName:


[User Defaults] Failed to read values in CFPrefsPlistSource<0x1742fba00> (Domain: xxxx, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null)): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd


If I am writing then I get the following additional error:


[User Defaults] Attempt to set a non-property-list object {

8400 = 1;

} as an NSUserDefaults/CFPreferences value for key kUserDefaultsFeatureTrackingKey


However the object I am writing to NSUserDefaults is a standard NSDictionary with NSNumber as key and NSString as value.


Did anyone succeed in getting NSUserDefaults with App Groups working properly on iOS 10?


Thanks!

I'm seeing this as well with the Xcode 8 GM on iOS 10 devices.

It looks like Apple is now requiring iOS apps to prefix app groups with their teamID... but I haven't seen apple respond to this so it's hard to figure out


https://forums.developer.apple.com/thread/57026


https://forums.developer.apple.com/thread/63107


I filed a radar against this 28462221

Build with Xcode 8.1 Beta and you will see the same warning, but you will also get the value.

Did anyone find any solution? same error. xcode 13.2 trying to use UserDefault in Network extension.

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

Ditto. iOS 14.4. This was working now its not.

Seems like this should have a solution by now, but I am seeing it on iOS 17.x !

What is going on?

I also encountered this problem on macOS 15 xcode 16

Cannot Access NSUserDefaults in App Group on Device
 
 
Q