3

I am building a Mac app with an embedded share extension and I am trying to configure app groups to share data between them. In Xcode under Capabilities, I turned on App Groups and set a single value: $(TeamIdentifierPrefix)com.company.App in both the parent app and in the share extension. When I run the parent app, it creates a folder: Library/Group Containers/com.company.App (without the team ID). When I run the extension it creates a folder:Library/Group Containers/TEAMID.com.company.App with the team ID.

Why do the two executables create different containers and how do I define the same container for both?

Mike T
  • 1,163
  • 1
  • 11
  • 27
  • 1
    I'm having the same problem. For some reason `$(TeamIdentifierPrefix)` sometimes evaluates to an empty string. My workaround: Using the actual team identifier instead of the variable – nschum May 18 '15 at 16:16
  • @nschum same here - tried various things and variations, but it only worked for me after replacing the variable with a static string containing the team identifier. Thanks for pointing that out! – Jay Jul 31 '16 at 06:06
  • Although `$(TeamIdentifierPrefix)` worked fine for me on macOS 10.11, for example, with 10.12 I got a warning that I could only silence by using the literal "group" prefix: `group.$(TeamIdentifierPrefix).com.company.App`. See here: https://stackoverflow.com/questions/38275395/failed-to-read-values-in-cfprefsplistsource-ios-10 – ctietze Jun 17 '17 at 09:04

1 Answers1

0

You should not include the "App" extension in Xcode Capabilities.

Methods used to manage group containers are specific.

To access the group container, you should use in both applications the method [myFileManager containerURLForSecurityApplicationGroupIdentifier:TEAMID.com.company] without the APP extension.

To access the UserDefaults (that are shared by the two applications) and store them in the group container, you should call [NSUserDefaults alloc] initWithSuiteName:TEAMID.com.company]

Lionel_A
  • 550
  • 4
  • 12