swiftxcodemacoscommand-line-interfacexcode-command-line-tools

Setup an App Group for MacOS command line tool?


I am creating a runloop in a macOS command line tool to create a background service. I need to setup an App Group for this to enable communication with a Finder Extension.

Xcode does not allow to setup an App Group for command line tool.

Is there any way to setup an App Group for macOS command line tool?


Solution

  • You can manually edit the .entitlements file of your command line tool in the project.

    If you’re unsure about proper syntax, you can create a new regular app target in the project, set up an App Group for it using Xcode interface, then open .entitlements and copy/paste “App Group” value to corresponding file in your command line tool target.

    enter image description here

    The App Group capability will be included in the binary file, but I haven’t verified whether it will actually be honored by the operating system. Maybe there’s a reason it’s not available via Xcode UI for this kind of target.