Running MacRuby and HotCocoa on Snow Leopard

I spent some time over the weekend playing around with MacRuby and HotCocoa, trying to put together a simple Mac application.

Getting MacRuby and HotCocoa running on Snow Leopard wasn’t entirely as easy as it should have been, though. Here are some of the hoops I jumped through.

MacRuby via RVM

I like RVM (go Wayne!) so I installed MacRuby that way. Fortunately - for me - that was only a matter of

rvm install macruby

BridgeSupport via downloaded installer

Supposedly this is only necessary if you’re still on Snow Leopard, but you need BridgeSupport.

You can grab it from the MacRuby site - at the time of writing Preview 3 is the most recent version. After downloading it, unzip it and run the installer.

HotCocoa via Bundler

HotCocoa is a Ruby-style interface to Cocoa, basically a way to create your user interface. Unfortunately, it seems the project is in a state of limbo and the official gem isn’t the one you want.

There is an active fork on GitHub that supports 64 bit architectures and actually works, so we want that.

After messing about with this for a while, struggling with making sure I got it installed as part of RVMs gems, not the system gems, and usable via rake, instead of macrake and what have you, I ended up using Bundler for bringing in the forked gem.

# Gemfile
gem 'rake'
gem 'hotcocoa', :git => 'https://github.com/ferrous26/hotcocoa.git'

Note that rake is also added to the Gemfile. Without it I was getting a bunch of seemingly unrelated errors, but this worked in the end. Just remember to do

bundle exec rake run

to run your application. Without it, you’ll be running RVMs macrake and you didn’t install the HotCocoa fork under that.

App away

With the above out of the way, I was able to happily code my way to a working Mac app using Ruby. That is pretty sweet.

I’ve not been able to really get along with Objective-C yet, so I’m hoping MacRuby can be a gateway drug for me.