Question

I wrote an Applescript, which uses display dialog and choose from list to allow to me to easily/quickly adjust some settings on my computer via a UI. I exported it from Script Editor as an Application, and it works great!

However, philosophically and aesthetically, I really believe this Applescript ought to live in System Preferences. In other words, I want to make it into a Preference Pane, instead of an Application Bundle.

I noticed that .prefpane's and .app's use a similar folder structure. Is there any sort of file trickery that will allow me to create a prefpane out of my Applescript without using XCode, similar to how a shell script can be turned into an app bundle by adding an info.plist and placing an executable in the right location?

Alternately, if this is stupid and XCode is required, can instructions be provided that do not assume prior knowledge of Objective-C or Swift?


Note: I am imagining something like the Java Control Panel, which launches from System Prefences but opens in a separate window. I'm well aware I can't build a proper System Preferences layout with just Applescript!

Was it helpful?

Solution

Xcode Required

No, Xcode is required to build a preference pane on macOS. A preference pane is a specialised CFPlugIn bundle that registers a set of callback functions. From there, an Objective-C runtime can be set up and a view provided to the host application.

Today, with macOS 10.15, the CFPlugIn plug-in architecture appears to be supported but not widely promoted by Apple. Applications using plug-ins require additional sandboxing/hardening requirements. I expect they will be phased out or required to operate within their own isolated processes.

Simple Preference Pane Example

Apple's archived Implementing a Simple Preference Pane provides a tutorial that may be enough to convert your AppleScript approach to a Preference Pane.

Having written and supported a commercial product that used a preference pane for much of macOS's early years, I recommend sticking with an application approach.

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top