Is there an Apple-supported way on macOS 15.6 to run a sandboxed local storage service under a dedicated non-root user account, with a sandboxed SwiftUI client and administrator-authorized installation?
OK, cool.
So, much of what you’ve described is feasible. You can create a sandboxed launchd daemon, install it from a sandboxed app with SMAppService, and communicate it over XPC using an app group.
IMPORTANT If you’re sandboxing your product because you intend to ship it to on Mac App Store, I can’t promise that App Review will approve it. Historically, App Review has not allowed apps to run code as root, but there’s a bunch of subtlety to that position and I can’t give you definitive answers about their policy. If you want that, talk to App Review directly.
The problem is this bit:
Role accounts have always been a challenge on macOS and this scenario is no exception. Your can tell launchd to run your daemon as a specific user via the UserName property. See the launchd.plist man page for details. However, I don’t believe that’s compatible with App Sandbox. I was talking about this with another developer just recently. Now where was that thread …
Oh, here it is: Sandboxed helper keeps running after the app is turned off in Background App Activity
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"