Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Create a Scripting Definition File

One option for creating an sdef file is to simply take an existing sdef, such as the one distributed with the Sketch application, and modify it for your application. You can do that with the following steps:

Important: As noted previously, starting in Mac OS X v10.5, the file CocoaStandard.sdef in the location /System/Library/ScriptingDefinitions provides an sdef for Cocoa’s Standard suite, and you can use an xinclude statement to include it into your application’s sdef file. For more information, see the Scripting section of Foundation Release Notes.

  1. Copy the file Sketch.sdef and rename it for your application (for example, MyApplication.sdef).

  2. Edit the sdef file in a text editor (in Xcode, select the file and choose File > Open As > Plain Text File to open the sdef as plain text). Rename the Sketch dictionary element, so it looks something like the following:

    <dictionary title="MyApplication Terminology">
  3. Rename the Sketch suite element and change its code, so that it looks something like the following:

    <suite name="MyApplication Suite" code="MyAp"
        description="MyApplication information.">
  4. Replace the scriptability information in the renamed suite element with the information for your application, as described in “Add Information to the Scripting Definition File.”

Creating an sdef file from scratch is quite similar, and also includes copying information for the Standard and Text suites. To create a new sdef file:

  1. Create a plain text file with the extension .sdef (for example, MyApplication.sdef).

  2. Add XML version and document type information. (All sdef files start with this information.)

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
  3. Your sdef must contain a dictionary element as the root element. The dictionary is typically named after your application, as shown in previous steps. The complete dictionary element from Sketch is shown in “Dictionary Element.”

  4. If your application supports any of the commands, classes, or other scriptability information defined in the Standard and Text suites, as most do, you should copy the suite elements for those suites into your sdef from an existing sdef file, such as Sketch.sdef.

    Important: You should delete any information in the default Standard and Text suite elements for features your application does not support.

    For more information, see “Suite Elements.”

  5. Add one or more suite elements for your application’s scriptability information.

  6. Fill in the scriptability information in the suite element (or elements) for your application by adding whichever of the following kinds of XML elements your application uses:

    1. Classes (see “Class Elements”)

    2. Commands (see “Command Elements”)

    3. Enumerations (see “Enumeration Elements”)

    4. Simple structures (see “Record-Type Elements”)

    5. Simple types (see “Value-Type Elements”)

    Your suite elements can refer to definitions from the Standard or Text suites that you've copied into your sdef.

To add an sdef file to the project for your application, see “Add the Scripting Definition File to Your Xcode Project.”



< Previous PageNext Page > Hide TOC


Last updated: 2008-03-11




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice