To use Scripting Bridge you need to generate header files from the scripting definitions of the application in question. The Preparing to Code section of the Scripting Bridge Programming Guide leads with the following:
Before you begin writing any Scripting Bridge code for your project, there are a few steps you should complete:
- Generate header files for all scriptable applications that your code is sending messages to.
- Add these files to your project.
- In your header or implementation files, add #import statements for the generated header files.
- Add the Scripting Bridge framework to your project.
It goes on to say:
To create a header file, you need to run two command-line tools—sdef and sdp—together, with the output from one piped to the other. This is the recommended syntax:
sdef /path/to/application.app | sdp -fh --basename applicationName
So, for scripting using System Events you'd run:
sdef /System/Library/CoreServices/System\ Events.app | sdp -fh --basename SystemEvents
This would generate SystemEvents.h
, containing a definition for SystemEventsApplication
, which you can then include in your project.