← Home

The Case of the Missing Xcode Template

Over the course of the past few months, I've been slowly wrapping up the development of a little Mac utility and preparing it for release. Part of that process is implementing support for the various forms of automation possible on macOS.

Adding AppleScript support and a shortcut for Shortcuts was reasonably simple with a little bit of googling. One might expect that the process of adding an action for Automator, the automation system added in OS X 10.5 and spiritual ancestor of Shortcuts would be similar and according to the tutorials I could find, it is — but there turned out to be a bit of a problem.

Following the instructions of online tutorials, it should be possible to select "Automator Action" from the sheet presented when adding a new target to an existing project or when creating a new project in Xcode, but this option is absent in Xcode 14.3. As it turns out, the Automator action template was removed some time ago. I suppose Apple thinks everybody should be focusing on writing shortcuts instead, but I wanted to support Automator since this utility supports versions of macOS back to 10.13 High Sierra, which debuted in 2017 when Shortcuts was still a third party iOS app named Workflow and had only just been acquired by Apple.

So I signed into the Apple developer portal and downloaded a copy Xcode 10.3, dating back to 2019, which I figured would have the template, and it did! Great, so all I need to do is copy the template to the appropriate folder, restart Xcode, and I should be able to create Automator actions, right?

Well, kinda. While the template did indeed show up in the new project sheet as it should, its icon didn't match the style adopted by recent versions of Xcode, it didn't offer a choice of language to create the project with (locked to Objective-C), and after creating the project Xcode couldn't find the action's Info.plist file.

There's apparently a version of the template that supports Swift that was made by an ex-Apple engineer, but I wasn't able to find it, so I set out to build my own.

Overall, the process wasn't too difficult, and that can largely be credited to a (blog post on Use Your Loaf and a GitHub gist documenting the innards of Xcode templates. Probably the most annoying part was the debug loop, which looked something like [tweak template] → [restart Xcode] → [create project using template] → rinse and repeat.

The updated template can be found on its project page on GitHub and is open for pull requests. If you'd like to read a little bit about how to use it and the bumps you might encounter in doing so, take a look at my other post Creating an Automator Action in 2023.