Apparency
Automating with AppleScript
Apparency is a scriptable application, which means that you can automate it using AppleScript.
The Apparency scripting dictionary is thoroughly documented, and contains many bits of sample code. You can open the scripting dictionary directly from Script Editor, of course; or from Apparency, use Help > Open Scripting Dictionary.
If you're using AppleScript in any significant way, we highly recommend checking out the venerable Script Debugger application. While you can get by with the built-in Script Editor application, Script Debugger is more capable and better designed in every way — yes, it costs Actual Money, but it's well worth it.
In addition to AppleScript, there are other scripting dialects that are built upon the same Open Scripting Architecture (OSA).JavaScript for Automation (JXA) was introduced back in OS X 10.10 (Yosemite), and allows you to use modern JavaScript for communicating with scriptable applications. On the upside, you get the built-in capabilities of the JavaScript language, including all of the improvements of the last decade, because JXA is built on the same JavaScriptCore engine that underlies Safari. On the downside, JXA itself seems to have been largely neglected in the last decade — although it does still broadly work. Apple has done nothing with JXA documentation since OS X 10.11 (El Capitan), but this site by Christian Kirsch is a fantastic resource.
Alternatively, the Scripting Bridge was introduced back in Mac OS X 10.5 (Leopard), and allows you to use Objective-C for communicating with scriptable applications. For the shrinking number of us that still like Objective-C, the appeal is obvious. But the scripting bridge seems to be neglected about as much as JXA. The API is still described in the active documentation, but important conceptual information — such as how to generate bridging headers — is relegated to the archive.
A few examples of how to use Apparency via AppleScript follow. We've also translated them into the JavaScript for Automation (JXA) dialect; use the buttons at the top of each example to switch between languages.
This first script demonstrates how to open an application in Apparency, and how to get at some of the basic attributes of the
app, such as the supported processor architectures, macOS version requirements, and code signature status. This script also
demonstrates how you can extract the app icon (with a specific image format and size) and write that to a file to use elsewhere
(here, we show it in the display dialog
alerts):
The above example examines only the top-level app, but many (if not most) apps contain various sub-components.
You can traverse the component hierarchy explicitly from AppleScript, by asking for the components
of the
root component
, and continuing onward until you reach the bottom — this is most naturally done with a recursive handler.
However, most of the time, you won't be interested in the structure of the hierarchy, so Apparency also
provides a find components
command, which can be used to easily get all of the components at once,
in a single list
. This script uses the find components
command to check all the components of
an app against some sort of local policy — such as that everything must be Developer ID-signed and notarized:
As an alternative to the above, it can be more succinct to apply a standard AppleScript
whose
clause to the find components
command. You can even use
uniform type identifiers (UTIs) to look for components of certain kinds:
We end with a more complex example, where we use Apparency to validate an app prior to distribution, checking for certain attributes that we want all components to have upon release, and using Numbers to create a summary report:
The above examples give a flavor of using AppleScript with Apparency, but there are many other properties and elements you can use. Again, check out the scripting dictionary for more information and many more examples.