Collective Idea

Collective Idea Logo

Tim Bugai

5 Awesome Things About RubyMotion

By Tim Bugai on May 11, 2012 in iOS, Objective-C, Ruby, and RubyMotion

Last week HipByte released RubyMotion and although I was originally skeptical, I’m now fully on board. I wouldn’t consider myself an Objective-C developer over, lets say, a Ruby developer or C# developer. I’m simply a developer that likes to learn. When a client brought in an idea that needed an iOS app, I wrote it in Objective-C with Xcode like a good boy. The size of the app made it perfect to rewrite in RubyMotion which gave me a chance to compare and contrast.

1. Bridging the gap!

Bridging between Ruby and Objective-C methods is nearly seamless. We can call [NSString +stringByDeletingPathExtension] on a string we’ve created with the normal ruby syntax.

str = "index.html"
if str.stringByDeletingPathExtension == "index"
  puts "found the index"
end

2. Less is more…

No more ugly and long NSDictionary allocation syntax. RubyMotion treats ruby hashes as NSDictionaries.
NSDictionary *rules = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber NumberWithBool:TRUE],"RubyMotionIsAwesome",nil];

can be simply rewritten as

rules = { RubyMotionIsAwesome => 1 }

3. What is that parameter for?

Named parameters. I don’t know why all languages don’t include these. They are tremendously helpful for readability.

self.navigationController.pushViewController(view_controller, animated:true)

4. Add dependencies

You can add project dependancies quickly. Just add the frameworks name to the dependency array in the projects rakefile.

Motion::Project::App.setup do |app|
  # Use `rake config' to see complete project settings.
  app.name = 'TestProject'
  app.frameworks << "AVFoundation"
end

5. Deployment

Deploying your app with TestFlight to beta testers is streamlined with the addition of the motion-testflight gem. Instructions on setting it up can be found at the RubyMotion page by following this link

Once you have it setup, its super easy to deploy to TestFlight

rake testflight note="a new revision"

We’ve already got plans to expand our use of RubyMotion in the near future. Being primarily a Ruby shop, RubyMotion means the ability to pair even if one isn’t comfortable with Objective-C and thats the biggest win of all.

By Tim Bugai on May 11, 2012 in iOS, Objective-C, Ruby, and RubyMotion

2 Comments

  1. Christopher Truman

    Christopher Truman May 11, 2012 http://ctruman.info

    So yes, its awesomesauce, has sweet syntax, easy dependency listing, and a REPL (http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) .
    But is it a valid choice for a production application? Unit tests, UI Automation, integration with apple profiler tools and debugger, consistent updates with Apple iOS updates. ┬áThese are the reasons why most professional iOS devs won’t be immediately switching to Ruby Motion.

  2. Christian

    Christian May 11, 2012

    @Christopher Truman

    I think your stating the obvious here, the product is only a week old.

    Come to the dark side…Luke

Post a Comment

Contact Us

Find us on Google Maps
Collective Idea
44 East 8th Street, Suite 410
Holland, Michigan 49423 USA 42.790334-86.105251

Follow us on the Interwebs

We are currently available for medium and long term projects. Please get in touch if we can be of service.