Wednesday, January 9, 2019

Adding a Command Line Tool Helper to a Mac App Store App

Timo Perfitt:

During testing, the command line tool continually crashed with a “Illegal Instruction: 4” both in the app and when I ran the tool outside the app on the command line. Turning off code signing (or not signing the app) make the issue go way, but code signing is required for submitting to the Mac App Store.

[…]

Long and short of it:

  1. The command line tool must have a Mach-O load command for LC_VERSION_MIN_MACOSX. It can be set using the GCC flag “-mmacosx-version-min=10.12” (change 10.12 to what makes sense).
  2. Command line tools must be signed with an entitlement that has exactly 2 rules: sandbox and inherit. It can be set with the codesign command. All other rules are inherited from the main app and should be set there.
  3. Pretty sure that the command line tool must be in the MacOS folder or a perhaps a folder named “Helpers”. I put mine in the Executables folder in a Copy Files build phase[…]

The exception is if your app has a command-line tool that is meant to be invoked by the user. Then the “inherit” entitlement would get in the way because it’s not being run from your app.

Comments RSS · Twitter

Leave a Comment