I have 2 Apps.
- A sandboxed native Mac App written in AppKit/SwiftUI.
- A Catalyst App.
I would like them to be able to communicate with each other. I assumed I would be able to do this using a shared App Group but I can't get it to work and I think this is because the App Group naming conventions appear to be different.
As far as I can make out:
- A Mac App uses App groups prefixed with the team ID
- A Catalyst App uses the iOS App groups which are prefixed with
group.
I have tried multiple combinations of different prefixes to try and make this work but without success.
I have been "testing" this by using UserDefaults(suiteName: appGroup)
and then attempting to read write values between the 2 Apps but without success so far.
My questions are:
- Is sharing an App Group between Catalyst and native technically possible?
- If it is possible what is the magic combo of App Group prefixes that makes it work?
- If it is not possible then do I have any other options for communicating between a sandboxed Mac App and a Catalyst App?
Is sharing an App Group between Catalyst and native technically possible?
Yes.
If it is possible what is the magic combo of App Group prefixes that makes it work?
Use the Developer website to create an iOS-style App Group — that is, group.UUU
where UUU
is unique — in your team and then use that app group ID in both apps.
Add that group to the com.apple.security.application-groups
entitlement to both apps.
On macOS this entitlement does not need to be authorised by a provisioning profile. That checking is deferred until you submit your app to the Mac App Store.
IMPORTANT If you’re using Xcode, be aware that it really wants to add your Team ID as a prefix to your app group ID. Dump the entitlements of both apps to make sure that hasn’t happened:
% codesign -d --entitlements - /path/to/your.app
I have a to-do list item to update the app groups docs to cover this (r. 92322409). It is, alas, a very long to-do list )-:
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"