Tuesday, February 2, 2010

Create a MacRuby HotCocoa App

You can create an OS X app quickly in Snow Leopard (OS 10.6.x) or later with MacRuby and HotCocoa.

Much of this information was provided in Isaac Kearse's post, Packaging A HotCocoa Application, which I'd recommend reading also as it has more information than I've included, and a lot of this is copied as a backup from Isaac's post. It's Ruby, so a lot of it should be familiar.

1. Download MacRuby.

2. Double-click on the zip file to extract it and double-click on the package inside the extracted directory to start the install. Just go with the defaults.

3. You may want to kill off terminal.app if you have it running and restart it, just in case the install put anything into the environment.

4. Use the following to install the hotcocoa macgem:

sudo macgem install hotcocoa

5. Change to the directory that you want your project directory to reside in:

mkdir -p /path/to/my/projects/
cd /path/to/my/projects/
6. Create a sample hotcocoa app:
hotcocoa nameofyourapp

Once you've done what you want, you can build and run your sample hotcocoa app via:

cd nameofyourapp
and deploy it via:
macrake deploy
If it won't work, run it so that you can see the error in terminal.app:
macruby lib/application.rb --debug

If you're curious, you can see what other macgems are available via:

sudo macgem list --remote
If you want to include a custom icon, see my other post.

Again, thanks much to Isaac Kearse's post, Packaging A HotCocoa Application, which contains even more information than I've provided here.


Scott Kyle said...

sudo macgem install hotcocoa


Gary S. Weaver said...

Fixed. Thanks, Scott!