Xcode's Plugin Interface : Specification Files

Table of Contents

UP (Xcode's Plugin Interface)
1. Generic Informations about Specification Files
2. File Type Definition (.pbfilespec)
3. Language Definition (.pblangspec)
4. Build Rules (.xcbuildrules)
5. Installing Your own Specification File

1. Generic Informations about Specification Files

These files are in fact property lists, and often use the ASCII format. However, if you wish, you may use the XML or binary formats for property lists.

In each .pb«thing»spec file, you have an array of specifications of type «thing».

Sample file containing two specifications :

(
    {
        Identifier = com.domain.myxcodeplugin.spec1;
        Name = "Spec 1";              // there's a space, so quotes are required
        Class = MyOwnObjectiveCClass; // there's no space, so quotes are not required
    },
    {
        Identifier = com.domain.myxcodeplugin.spec2;
        BasedOn = com.domain.myxcodeplugin.spec1;
        «AList» = ("aaa","bbb");
        «ABoolean» = YES;    // or NO
    },
)

The generic properties, used in every kind of specification, are :

2. File Type Definition (.pbfilespec)

You'll find sample files here :

/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/Built-in file types.pbfilespec

/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/Standard file types.pbfilespec

Specific properties of file type definitions used for identification (Xcode run all these tests to find the type of a file) :

Specific properties of file type definitions describing content :

Specific properties of file type definitions used for building :

Specific properties of file type definitions used for wrappers :

3. Language Definition (.pblangspec)

You'll find a sample file here :

/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/Built-in languages.pblangspec

A language specification describes the syntax of a language (for syntax coloring), how it should be indent (for automatical indentation - not documented) and other things like included files or function name extracting (for the function popup - not documented).

A sample specification :

(
    {
        Identifier = mylang;
        Name = "My Language";
        Description = "My Language"; // may be longer
        BasedOn = "pbx_root_language";
        SourceScannerClassName = MySourceScanner;
            // (optionnal) name of an Objective-C class inheriting from PBXSourceScanner
        SupportsIndentation = NO;   // only work for C-like languages
        Indentation = {}            // indentation definition (not documented)
        SyntaxColoring = {          // syntax definition (see next paragraph)
            «prop» = «value»;
            …
        }
    }
)

Now, the interesting part : how to define a language syntax. The syntax is not defined by a real user grammar like in other IDEs, but by a generic grammar implemented inside Xcode, with many parameters modifiable in the language specification. Theses parameters are :

4. Build Rules (.xcbuildrules)

This specification is used to informe Xcode which compiler it must use for a given file type.

(
    {
        Name = "ME source rule";
        FileType = "sourcecode.me";
        CompilerSpec = "com.domain.me.compilers.";
    },
)

5. Installing Your own Specification File

There's two possibilities :