Search code examples
objective-cmacosautomatorcodesign

How to embed Automator Action in App Bundle for delivery


I'm on Objective-c Xcode 11, macOS not iOS.

I have a small app in objective-c, sandboxed. To make it more accessible i added script support and therefore developed some Automator actions.

I want to embed them in the app bundle so the user doesn't need to install them seperately.

Regarding the documentation this works by placing them in the app bundle like this:

myapp.app/Library/Automator/actionHere

What i tried:

I created an archive and copied the finished product (automator action) to my app folder (in finder) and added it to the project (without copying). Then i added a copy files phase to copy it to the above folder (selected 'Wrapper' + 'Library/Automator'). I tried both with "Sign on copy" and without.

Unfortunately, signing of the app fails with "unsealed contents present in root directory" - without the automator action it builds fine.

Team ID for codesigning and certificates match for both apps. Base identifier is the same e.g. com.mycompany.product and com.mycompany.product.automator.action1

Then i tried to embed the Automator project as subproject. But that failed at all....

How can i either add the Automator project as subproject of the main app project and get the final automator ation in the above mentioned directory OR how can i add the already codesigned Automator action to the app properly so that codesigning doesn't fail.

Regards Pat


Solution

  • Automator action

    • Create an archive for distribution
    • Codesign it with the same certificate as your main app

    Main App

    • Copy the final product to your main app (in finder) and add it to your project
    • Remove it from "Copy resources" build phase
    • Create new copy files phase (right after the copy resources phase), select "Resources" and enter "Library/Automator"
    • Add it to the new copy files phase

    Test it

    • Create an archive of your main app
    • Copy the product to the application folder (important - otherwise action won't be installed by OSX
    • Open Automator, you should find your action there. If not - restart.