App Group, Shared User Defaults, Finder Sync Extension Not getting user defaults.

I have an app group. Finder Sync Extension and Main app register for the group.


Main apps sets a BOOL preferene:


NSUserDefaults *userDefaults = [[NSUserDefaults alloc]initWithSuiteName:GroupIdIsHere];

[userDefaults setBool:YES forKey:keyHere];

[userDefaults synchronize];


Now when I run the Finder sync extension, I retrieve the preference:


NSUserDefaults *userDefaults = [[NSUserDefaults alloc]initWithSuiteName:GroupIdIsHere];

BOOL settingOn = [userDefaults boolForKey:keyHere];

//I get NO, even though it was set to YES.


Now the Finder sync extension is getting NO. The main app does get YES on the next app launch though.

Potentially related log?


attempt to write to a container /var/root/Library/Group Containers/GroupIdIsHere that does not yet exist. Using client-provided container path without resolving symlinks.

Nearly ten years later I'm having the same problem. Forgot I even made this post (found it by searching).

Main app writes the preference but the extension isn't getting the updated value.

FWIW main app is not sandboxed but the Finder extension is (because it has to be). But I'm pretty sure I've gotten this to work before...not sure what's goin on

Accepted Answer

Meh. Somehow I must've done something (or there is some Xcode bug) but I got Xcode to generate another .entitlement file for the extension without realizing it.....it was called something like:

MyEntitlement.release.entitlements....and it was set to Release mode. The group container ID was only getting added to the release mode entitlement file, not the .entitlement file being used in debug mode.

Fixed that.

App Group, Shared User Defaults, Finder Sync Extension Not getting user defaults.
 
 
Q