MacOS – Preferable way to ship a command line tool with the OS X *.app

applicationscommand linemacos

I'm working on an Electron based application to write OS images to removable drives, which is being packaged as an *.app for OS X.

Along with the GUI application, I'd like to ship a CLI version bundled with the app, that does the same thing, however I'm not sure how to make it accessible to the users.

I guess I could put the binary in Contents/MacOS and ask the users to add this to the PATH, however this would be a very bad experience for the users.

What is the recommended way to ship an command-line tool along with your *.app?

Alternatively, I could add another *.app for the CLI tool inside the DMG I distribute to users so they optionally install as well, but having two separate *.app would be a bit confusing, and in any case, there doesn't seem to be a way to instruct an *.app to make its binary accessible to the PATH.

Best Answer

You can place a link to the contents/macos/app in a location that is in the users path. You don't need to have a separate binary with this approach but your app does need to handle command line arguments. That is not hard to do, but the details of that are beyond the scope of this site.