This is the first of a series of posts on using Xcode to edit Ruby files.
For those that are familiar with Xcode, this will likely not be very informational, but for those of us that are new to Apple's programming editor, perhaps it will be useful. Xcode ships with Apple's developer tools which can be downloaded here (free/subscription required). A little known fact is that Xcode syntax highlights Ruby source code, so if you aren't a VIM or Emacs disciple, perhaps Xcode is for you.
First things first. If you always want to edit your Ruby files using the Xcode editor, use the Finder to browse to a folder with a Ruby (.rb file) in it. Then single click on the file (to select it) and then chose the File/Get Info menu item. This will present a nice long information panel. In that panel there is an 'Open with:' section that has a drop down in it. Select that then choose 'other'. This will bring up a file browser. The Xcode .app file is located in /Developer/Applications. After you select 'Xcode' make sure and select the 'Always open with' checkbox in the lower left corner, then press the 'Add' button. The drop down should now say 'Xcode' and if you click on the 'Change All...' button the Finder will open all Ruby files with Xcode.
That's it. Now, whenever to double-click on a Ruby (.rb) file in the Finder, it will open the Xcode editor. Also, if you are at a command line and there is a Ruby script you want to edit, you can just type 'open myscript.rb' and it will open the default application for .rb files...which we have now made Xcode!
In my next post I will discuss setting up the editor using the Preferences in Xcode that make editing Ruby extra special (like showing line numbers, indenting, coloring, etc). I will conclude with post on using the project capability of Xcode to edit groups of Ruby files.
Can't wait for the next installment.
I'm a python programmer and have yet to find simple instructions like this for python and xcode. Any notes on how to run code from xcode will be much appreciated!
Posted by: Jon | Saturday, March 20, 2004 at 08:43 AM
What about syntax coloring for Ruby files. I can't get XCode (V1.1) to color code my Ruby files. Anything special I need to do ?
Posted by: Martin Dufort | Wednesday, April 07, 2004 at 09:14 PM
Syntax coloring worked out of the box for me with my Panther installation. Not working for you?
Posted by: Chad Fowler | Sunday, April 11, 2004 at 07:12 PM
Dunno what I did but it is working correctly now. Thanks anyway
Posted by: Martin Dufort | Tuesday, April 13, 2004 at 06:49 AM
Tips on using the Test::Unit with XCode would be nice too!
Posted by: Urban Nilsson | Tuesday, May 11, 2004 at 12:06 PM
I read a post by David Hansson where he gave up using Xcode in favor of textmate. I am currently on the 30 day trial of textmate and it is cool so far, but can you tell me what other editors you have used, and what is making you stick with Xcode? Thanks for your help!
Posted by: Robert Lyons | Monday, May 02, 2005 at 10:50 PM