applescriptosx-gatekeeper

Is it possible to automatically code sign an AppleScript app?


I'm creating multiple AppleScript apps, each of which bundles presentation HTML into a single icon and opens it with Safari. I'd like to code sign the resulting Presentation.app file to prevent Gatekeeper from flagging it.

I know that I can manually open each Presentation.app and re-export it, selecting the code sign option. I'd like to be able to do this step automatically.

Each Presentation.app is built from a combination of languages and markets and assembled with an automatic process - which is itself written in AppleScript. So the ideal solution would be AppleScript code that automatically signs each Presentation.app with my developer ID.

So far, I've tried recording the actions in Script Editor with zero results. I've explored the Script Editor dictionary to see if there are options that would support this. The closest I have found is the save verb in the Script Editor Suite, but it doesn't display parameters for code signing.


Solution

  • Using the command line codesign program can do this. Something like:

    codesign -s "Developer ID Application: <use your identity>" Presentation.app

    And within AppleScript, call this with do shell script like so:

    do shell script "codesign -s \"Developer ID Application: <use your identity>\" Presentation.app"

    It is probably going to be necessary to remove extended attributes before signing:

    do shell script "xattr -cr Presentation.app"