Shared defaults between macOS App and Extension

Hi all,

TL;DR; All of a sudden we can no longer use shared defaults between a macOS app and an extension.

We've got a CTK extension that we are working on for macOS, and we have hit a bit of a stumbling block right in the middle of development.

We are a bit atypical as the extension is sandboxed like normal, but the container app isn't. We have a common defaults suite name that we use to hold a few bits of data that both the .app and .appex need. All of a sudden, this data sharing has stopped working.

The docs for UserDefaults say that extensions on macOS are exempt from requiring an app group for shared preferences and this has been our experience so far. Now though it doesn't seem to be the case. The extension is refusing to read the shared domain and making its own copy of the settings inside of its sandbox. If I jump into the debugger in the extension I can see that it can't read the shared domain.

This is currently baffling us as it has been working just fine throughout development and beta testing.

I had the thought that it could be that some change now requires an app group, but the previous builds continue to work fine. I've requested an app group from our dev ops team so that I can try that and see if things improve.

Has anyone else run into something like this? Most of the search results on the web are about iOS appex sharing of defaults. Since that is significantly different than macOS I thought I would ask here.

Thanks,
Josh

Replies

Updating the thread...

Using an app group works just fine for sharing preferences but that shouldn't be required between an app and included appex.

If I can make a reduced test case I'll file a feedback on it.
Did you recently sandbox? My understanding is that sandboxing requires app groups.

I've been using app groups since 10.10 (fuzzy, but since Extensions were introduced on macOS), because this was the only way I could get sharing user defaults to work. But it's also the time I started sandboxing everything, so that might be the cause.