MacOS – Forcing `open` command to open unsigned app

code-signingmacosSecurityterminal

I've got my Security preferences set to allow apps downloaded from "Mac App Store and identified developers." When I try to open an unsigned app:

open xyz.app

I see the following:

App can't be opened

Usually, I right-click on the app and click "Open". This brings up a similar dialogue, but this one includes an "open anyway"-type button:

App can't be opened, with open button

Is there a way to do this only using the open command — something like:

open --even-if-unsigned xyz.app

Best Answer

  1. Create and add a Gatekeeper label to the app. (‘Approved’ is an arbitrary string.)

    spctl --add --label "Approved" /path/to/xyz.app
    
  2. Approve all apps with the label.

    spctl --enable --label "Approved"
    

    This only needs to be done once and adding the same named label to apps in the future automatically enables their access.

  3. Open the app as usual.

    open xyz.app
    

For more information about spctl (SecAssessment system policy security), see the man page.