I've had this running in the past for my other app (between a Today extension and the host app), however, for a brand new app created with Xcode 9.1 I see strange errors:
2017-12-25 17:16:42.077247+0530 Controller[851:11684] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x10470c970> (Domain: group.com.judepereira, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd
2017-12-25 17:16:42.079711+0530 Controller[851:11707] [User Defaults] Couldn't write value for key idc in CFPrefsPlistSource<0x10470c620> (Domain: group.com.judepereira, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access, switching to read-only
2017-12-25 17:16:42.081354+0530 Controller[851:11707] [User Defaults] Couldn't write value for key rules in CFPrefsPlistSource<0x10470c620> (Domain: group.com.judepereira, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): Operation not allowed, switching to read-only
I've followed the guides specified here and here. Moreover, what's even more weird is that it works perfectly within the host app. I see these random errors only when my Message Filter Extension tries to update the user defaults for this app group.
Here's how I'm updating it:
NSUserDefaults *defaults = [[NSUserDefaults alloc]
initWithSuiteName:@"group.com.judepereira"];
NSLog(@"idc=%@", [defaults objectForKey:@"idc"]);
[defaults setObject:@"judepereira" forKey:@"idc"];
Further, I've read here and here about how a reboot of the device solves it, and also that these error messages are just some spurious warnings.