defaults tool can't handle app group settings?

I have an app group to share settings between a main app and a helper. This is accessed using [[NSUserDefaults alloc] initWithSuiteName: @"FDHC2KMZ6V.com.jwwalker.autopairs.suite"]. What's puzzling me is that if I go to Terminal and enter

defaults read FDHC2KMZ6V.com.jwwalker.autopairs.suite

it tells me that the domain does not exist. Is this a bug in the defaults tool, or is there some trick I'm missing?

Accepted Reply

Is this a bug in the defaults tool, or is there some trick I'm missing?

Neither, really. The defaults tool far predates the advent of app groups, and we just haven’t got around to adding support for them. We have a bug on file for this already (r. 32691004).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Replies

Is this a bug in the defaults tool, or is there some trick I'm missing?

Neither, really. The defaults tool far predates the advent of app groups, and we just haven’t got around to adding support for them. We have a bug on file for this already (r. 32691004).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo How does one go about modifying stuff in the shared 'app grouped' plist if the defaults command does not support it? I would love to quickly modify, read & delete like I am normally used to with defaults. I found some workaround with killing cfprefsd but that's not working anymore. Direct modification in ~/Library/Group Containers/ does not work.

How does one go about modifying stuff in the shared 'app grouped' plist if the defaults command does not support it?

I don’t think there’s a built-in way to do that. If you find yourself needing to do it a lot, you could write your own command-line tool, or use a scripting language. Back in the day I used to do this sort of thing using PyObjC.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How does one go about modifying stuff in the shared 'app grouped' plist if the defaults command does not support it?

I don’t think there’s a built-in way to do that. If you find yourself needing to do it a lot, you could write your own command-line tool, or use a scripting language. Back in the day I used to do this sort of thing using PyObjC.

IMPORTANT Writing your own tool will avoid app data container authorisation alerts, as discused in WWDC 2023 Session 10053. See Trusted Execution Resources for a link to the details.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"