Erlang support in Apple's XCode IDE

Vance Shipley <>
Wed Aug 18 08:09:28 CEST 2004

I had another look at XCode today with a mind to seeing what it
could offer in my Erlang centric work flow.  After way too much 
time spent reverse engineering I came to the conclusion that it
isn't much help now, but it could be ...

I did however get basic syntax highlighting working and put Erlang
templates in place for targets and files.  I am giving up for now.
If anyone else is working on this, or wants to, here is what I found:

For user specific changes use a base path of:

$(HOME)/Library/Application Support/Apple/Developer Tools/

For local system wide changes use a base path of:

/Library/Application Support/Apple/Developer Tools/

The system resources are in:


By copying things from the system files I came up with the following
files to be added (relative to the base path).  The Specifications 
directory probably doesn't exist yet so create it.

Specifications/Erlang File Specification.pbfilespec:
    //  Erlang Source File Specification
        Identifier = sourcecode.erlang;
        BasedOn = sourcecode;
        Name = "Erlang source files";
        Extensions = (erl);
        ComputerLanguage = erlang;
        AppliesToBuildRules = yes;

Specifications/Erlang Language Specification.pbfilespec:
    //  Erlang Language Specification
        Identifier = erlang;
        Name = "Erlang";
        Description = "Erlang";
        BasedOn = "pbx_root_language";
        Extensions = ( erl );
        ComputerLanguage = erlang;
        AppliesToBuildRules = yes;
        SupportsIndentation = YES;
        Indentation = {
        SyntaxColoring = {
            CaseSensitive = YES;
            UnicodeSymbols = YES;
            IndexedSymbols = NO;
            CommentsCanBeNested = YES;
            String = (
                ( "\"", "\"" )
            SingleLineComment = (  "%" );
            DocComment = "%%";
            DocCommentKeywords = (
            Keywords = (
            PreprocessorKeywordStart = "-";
            PreprocessorKeywords = (

Those two additions get XCode to recognize that these are source
files and will get rudimentary support as such.  An editor is slected
and syntax highlighting is in effect.  The definition above for the
syntax higlighting was my first pass and is unquestionably incomplete/wrong.

To include an Erlang category in the menu for creating files you add the

File Templates/Erlang

In that directory you can create entries for different file types.
Name the directories with a .pbfiletemplate suffix:

File Templates/Erlang/Erlang File.pbfiletemplate/
File Templates/Erlang/Behaviour/application.pbfiletemplate/
File Templates/Erlang/Behaviour/supervisor.pbfiletemplate/
File Templates/Erlang/Behaviour/gen_server.pbfiletemplate/
File Templates/Erlang/Behaviour/gen_fsm.pbfiletemplate/
File Templates/Erlang/Behaviour/gen_event.pbfiletemplate/

In those directories you put your template .erl files.  You should 
have a TemplateInfo.plist as well:

File Templates/Erlang/Behaviour/gen_fsm.pbfiletemplate/fsm.erl
File Templates/Erlang/Behaviour/gen_fsm.pbfiletemplate/TemplateInfo.plist

   MainTemplateFile = "fsm.erl";
   Description = "An Erlang gen_fsm behaviour module source file.";

To include an Erlang category in the menu for creating targets add:

Target Templates/Erlang/

Target Templates/Erlang/Beam.trgttmpl:
    Class = Native;
    ProductType = "erlang.beam";
    Description = "Target for building an Erlang beam file.";
    CustomBuildSettings = {
        INSTALL_PATH = "$(HOME)/ebin";
        BuildPhases = (
                Class = Sources;

I think we need these files as well:

Specifications/Erlang Package Types Specification.pbpackspec
Specifications/Erlang Product Types Specification.pbprodspec

I gave up after quite some time trying to get the syntax right with 
these.  It looks like with the right incantations in these files you
could have a good deal of the supported features.

For what it's worth I get an "Internal Error":
File: /SourceCache/DevToolsBase/DevToolsBase-387/pbxcore/Target.subproj/PBXBuildSettingExpansion.m
Line:	237
Function:	PBXFindFirstMacroReferenceInRangeOfCFString

Assertion failed: macroNameRange.length >= 1


Vance Shipley
Motivity Telecom Inc.
+1 519 240 3684

More information about the erlang-questions mailing list