RubyMotion: Dreams Do Come True

The website for RubyMotion calls it “A revolutionary toolchain for iOS. It lets you quickly develop and test native iOS applications…using the awesome Ruby language you know and love”.
As a long-time Ruby (and Rails) developer, when I first heard about this I thought I was in a dream!

I have gone through those “…in 24 hours” books on iOS development. I have struggled with Objective-C (to the point that I dubbed it ‘Objectionable-C’). And I have fought with XCode’s peculiar “drag to connect an element with its event-handler” methodology.
The thought of writing pure Ruby that can be compiled into native iOS was thrilling. My imagination had me converting some of my Rails apps directly to iPhone apps with just a click!

RubyMotion does, in fact, compile to native iOS machine code. The apps you write with it are indistinguishable from Objective-C versions when submitted to Apple’s App Store. The code compiles down to LLVM machine code.
But, it is not quite as simple as writing MRI Ruby and compiling it to run on the iPad/iPhone/iPod.

Not quite. You still need to adhere to some of the structure and syntax of Objective-C.
However, the trade-off is more than fair. We get to apply our favorite Ruby idioms to iOS:

The Ruby Community to the Rescue

As stated earlier, this is not quite the Nirvana of writing Ruby code (that works in a Rails application, for example) and having it magically compiled to run on an iPhone. Although the iOS API is based on MVC and RubyMotion supports the concept of Controllers and Views, a working knowledge of the structure of iOS is still required when writing RubyMotion code.

Members of the active community continue to innovate and generate useful tools to aid in the progress of RubyMotion.

From the very beginning, the developer community began hacking and building, applying Ruby’s innate aptitude for Domain Specific Languages (DSL), and produced a set of utilities that “wrap” the cumbersome NeXTStep form with a more Ruby-esque syntax. The very first was Bubble-Wrap (appropriately named). Today you can find numerous tools to:

The build system is available as Open-Source on Github
Although RubyMotion is not free, all of these libraries and support tools have been created by the community and are available on Github. The development of RubyMotion has progressed at an impressive rate. HipByte, the company formed by Laurent Sansonetti – the creator of RubyMotion, is extremely responsive to the community with respect to fixes and updates.

My attempts to write iPhone/iPad/iPod/iAnything apps in ‘Obstinate-C’ had been a nightmare.
The ability to use flexible and forgiving Ruby and its expressive, English-like style make iOS development a dream now.

Resources to learn more

The RubyMotion website has an Introduction Video. There is also a Developer Center and FAQ on the site.
The Pragmatic Studio has a terrific Free Screencast that shows many of the highlights of RubyMotion.
For some deeper technical details, you can refer to the Runtime Guide on the RubyMotion website.
And, MotionCasts.TV is a set of community-generated screencasts specifically about RubyMotion.

A self-proclaimed ParaHacker and avid Logophile, Thom has been writing software since the days when ALL telephones had wires.
Leaving Fortran and COBOL behind and having become bored with Java, Thom is currently a Serial Rails Developer living in The Sunshine State.
When not working on Open Source projects, developing articles and tutorials for Learnable, or helping to manage the Sitepoint Forums as a Team Leader, Thom is playing Euro-Games.
With a reputation for puns and wordplay, Thom calls himself an avid Logophile and Polyphiloprogenitive Programming Polyglot.