Xcode 3's language support for Ruby is somewhat broken. Fortunately, fixing it only requires a few small modifications.
One major problem, Xcode doesn't know what .erb and .rake files are.
There should be a file:
/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Versions/Current/Resources/Standard file types.pbfilespec
Copy this to /Library/Application Support/Developer/Shared/Xcode/Specifications/, creating that directory if it doesn't exist. Editing the original works, but your changes will be overwritten if you update Xcode, better to just override the standard files.
Edit the html-like files entry (line 335 in mine) to add erb:
// html-like files
{
Identifier = text.html.other;
BasedOn = text.html;
Extensions = (shtml, jsp, rhtml, erb);
},
I did the same to add a "rake" file type, around line 543, and also added the line "FilenamePatterns = ("[rR]akefile");" to detect rakefiles without the .rake extension:
{
Identifier = text.script.ruby;
BasedOn = text.script;
Extensions = (rb,rbw,rake);
FilenamePatterns = ("[rR]akefile");
MagicWord = ("#!/bin/ruby", "#! /bin/ruby", "#!/usr/bin/ruby", "#! /usr/bin/ruby", "#!/usr/local/bin/ruby", "#! /usr/local/bin/ruby");
ComputerLanguage = shell.ruby;
Language = "xcode.lang.ruby";
IsExecutable = YES;
},
Next, the Ruby language syntax highlighting, selecting, etc need some tweaking. Copy the file
/Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/Current/Resources/Ruby.xclangspec
to /Library/Application Support/Developer/Shared/Xcode/Specifications/
By default, Xcode will select too much when doubleclicking. When trying to select an array identifier, it will select the opening [ bracket around the indices.
Go to the lines:
Identifier = "xcode.lang.ruby.identifier";
Syntax = {
StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_[";
Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_?[]";
And remove the [ and [] characters, which will make selections break at the brackets around array indices.
Now restart Xcode...the changes will not take effect until you do.