Review: RubyMotion iOS Development Essentials

rm-ios-devRubyMotion is a continued topic of interest on this blog, and I will likely have more posts about it in the near future. At this stage I am still getting comfortable with iOS development, but I would much rather be doing it in the friendly playground of Ruby rather than the Objective-C world. In addition to the RubyMotion book from PragProg, the next resource I would recommend is RubyMotion iOS Development Essentials.*

The book takes a “zero-to-deploy” approach, which is great for beginners trying to get their first app into the App Store. The first few chapters  will be redundant for developers who have worked with RubyMotion before, but they provide a helpful introduction to how RM works and the Model-View-Controller paradigm.

For several chapters the book uses the same example application, a restaurant recommender reminiscent of Yelp. Demonstrating code by building up from a simple application is a nice way of presenting the application. By the time readers have worked through these chapters they will have an example app that is more interesting than many of the toy apps in shorter tutorials.

Later chapters will benefit novice and experienced developers alike, because they fill a gap in the RubyMotion literature. Many tutorials overlook the process of testing RM code, and testing iOS in general can be challenging. The testing chapter of this book goes over unit testing, functional testing, and tests that rely on device events such as gestures.

My favorite chapter in the book was chapter 6, which goes over device capabilities. At 46 pages this is the longest chapter in the book, covering GPS, gestures, Core Data, using the Address Book, and more. I especially enjoyed working through the section on accessing the camera and Photo Library. This is difficult to test on the simulator since there is (obviously) no access to a built-in camera (as with certain iOS devices including some iPod Touch models), but the example app covers how to handle this gracefully.

Stylistically, it can be a challenge to lay out a book that uses iOS API jargon like UIImagePickerControllerSourceTypePhotoLibrary. There were some gripes with the authors’ choice of two-space indenting, but that is my preference so it did not bother me. One addition I would have preferred would be additional formatting for the code, using either colors (for the e-book) or bolding (for the print version) to distinguish function names and help the reader keep their place in the code. The apps themselves rely mainly on iOS defaults. This is common in tutorials, but it also helps them look natural in iOS 7. Most of the time I was working through the book I used the iOS 6.1 simulator, but it was no problem to upgrade to iOS 7.

As a whole this book is a thorough introduction to RubyMotion development. It has several key features that are missing from other RubyMotion tutorials, including an emphasis on testing code. This book makes a great resource for new RubyMotion developers, or developers who want to use more of the device capabilities.

*Note: For this review I relied on the e-book version, which was provided as a review copy by Packt Publishing.

RubyMotion for Complete Beginners

HelloWorldRubyMotionAccording to the RubyMotion guide for getting started, “RubyMotion is a toolchain that permits the development of iOS applications using the Ruby programming language.” In less formal terms it lets you write iOS apps in Ruby using your favorite development environment rather than Apple’s unpopular XCode IDE. This post assumes you have gone through the guide above but don’t have much other iOS development experience.

My number one recommendation for anyone coming to RubyMotion for the first time would be RubyMotion: iOS Development with Ruby by Clay Allsopp. This book has the quality we have come to expect from the Pragmatic Programmers. The code examples are clear and well-documented, encouraging you to work hands-on with RubyMotion from the first chapter.  The book website over at PragProg also includes a discussion forum where the author personally answers questions.

The Pragmatic Programmers also put out a RubyMotion screencast. Screencasts are popular within the Ruby-Rails community and seem to already be fairly widespread within the RubyMotion world.

My favorite RubyMotion screencast to date is Jamon Holmgren’s tutorial for making an app that displays several YouTube videos. In all I am pretty sure I wrote just over 100 lines of code for this demo app. I am certain that in Objective-C the app would have required much more code, and have been less fun to write. This tutorial uses the ProMotion tool that Jamon also wrote, which helps organize your app behavior based on “screens.” You can find a tutorial for getting started with ProMotion here.

If you would like to know a bit more about the background of RubyMotion and the people who use it, there are two podcast episodes I would recommend. The first is the Ruby Rogues interview with Laurent Sansonetti, the creator of RubyMotion. The second is Episode 29 of the Giant Robots Smashing into Other Giant Robots podcast (“The Most Ironic iOS Developer”). In that episode Ben Orenstein interviews two thoughtbot developers, one of whom uses primarily RubyMotion and the other uses Objective-C almost exclusively but has a bit of experience with RubyMotion. They give some nice perspective on the pros and cons of RubyMotion for iOS development and the show notes provide a number of other resources.

To keep up with new resources in the RubyMotion community, check out RubyMotion Tutorials. The code that I have written during this initial learning process is on Github.

Update 1: I forgot to mention that RubyMotion also offers a generous discount for an educational license if you do not plan to sell your apps on the App Store.

Update 2: Jamon Holmgren tweeted a new version of his tutorial this morning (1/30/13).