Hi, I have a app group registered in mac os app called gorup.com.company.app and i am saving the key/values in userdefaults to this with suitname. within the mac os app the group userdedaults write/read are working fine.
I have a switt cli app with same app group registered in the code signing entitilement for the swit cli app. trying to read the group user default key value registered in mac os app in swift cli app returning no value. this was working fine with macOS 26. Is there some changes have been made in macos 27 in regaard to this?
I’m surprised this worked on macOS 26.
To understand what’s going on here you need to read App Groups: macOS vs iOS: Working Towards Harmony. It explains the two app group ID styles on macOS: The original Mac-style one (TEAM_ID.x.w.z) and the iOS-style one (group.x.y.z). It also explains the entitlements-validated flag, which is critical to understand this behaviour.
You can use either app group ID to access an app group container and as a user defaults suite ID. However, if you’re writing new code then my advice is that you use iOS-style app group IDs. That’s the long-term future direction.
Doing this from a command-line tool is tricky, because:
- Your claim to that app group is based on entitlements.
- Those entitlements must be authorised by a provisioning profile.
- An command-line tool doesn’t have a bundle, and thus there’s no place to store that profile (r. 125850707).
The way out of this conundrum is to put the command-line tool in an app-like wrapper. Signing a daemon with a restricted entitlement explains this process, albeit in a very different context.
If you then want to make it easier for the user to run the tool, install a symlink to the executable within that bundle structure.
Keep in mind that the system needs your command-line tool to have an App ID, and by signed with the App ID entitlement, in order for it to associate your tool with its profile. Without that, depending on your exact setup, the system may allow your tool to run but it’ll run without the entitlements-validated flag, which will be very confusing.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"