From Ruby on Rails to RubyMotion - Writing your First iOS App with RubyMotion


Published on

This talk is targeted to developers who have experience with Ruby on Rails, but with little to no iOS development experience. We look at a series of gems that can help you get started with RubyMotion, including

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

From Ruby on Rails to RubyMotion - Writing your First iOS App with RubyMotion

  1. 1. RoR to RubyMotionWriting Your First iOS AppWith RubyMotionMichael DenomyBostonMotion User GroupJune 25, 2013
  2. 2. About Me• Tech Lead at Cyrus Innovation- Agile web consultancy with offices in NewYork and Boston-• Agile and XP practitioner since 2004- Passionate about TDD and pairing• mdenomy on twitter and github• Blog at
  3. 3. Goals• Capture my experiences getting startedwith RubyMotion- Help someone else along- Get ideas for where to go next• Target Audience- Developers familiar with Ruby on Rails- Little to no previous experience with iOS- Desire to learn• Some talk, some code
  4. 4. The VisionMVCRuby
  5. 5. The Reality initWithNibName?UIControlEventTouchUpInside?What’s a Nib?
  6. 6. More Cold Hard Facts• RubyMotion is not free- $199.99- No trial, but 30 day money back- There is a student discount program• iOS Developer Program is not free- $99 / year- Required to deploy to devices and distributevia AppStore• You will need to understand iOS SDK- iOS documentation is difficult to navigate
  7. 7. It Gets Better
  8. 8. It Gets Better
  9. 9. Good Stuff• Growing community with lots of onlineresources• More and more gems appearing thatprovide a Rails-like experience• Free to use the tools you like- Sublime plug in for RubyMotion has codecompletion and rake shortcuts
  10. 10. MVC in iOS• MVC is MVC right?• No “convention over configuration”- Have to wire things up manually• Slightly different terminology that Rails
  11. 11. UIViewControllers• Controller receives actions from theframework (e.g. view loaded) and theuser (e.g. button pressed)- Interacts with Models and View• UIViewControllers you need to know- UINavigationController- UITabBarController- UIViewController- UITableViewController
  12. 12. Models• Models are PORO’s in RubyMotion• Support built-in for- attr_accessor- attr_reader- attr_writer• Possible to serialize/deserialize datausing NSCoder and NSKeyedArchiver- Looked for other options to support storageand relationships
  13. 13. Views• UIView is a base class• Buttons, labels, date pickers, etc., allinherit from UIView• Views can have subviews- Simplifies screen layout and allows re-use
  14. 14. Let’s Look at Some Code• Basic Navigation- Application Delegate- Root View Controller- UITabBarController- UIViewControllers
  15. 15. MyWines App• I enjoy the occasional glass of wine.• I would like to have a way to track thewines I like and prices Ive paid for them- Record tasting notes- Record purchases and price info- Search for wine by name/producer- Save to Favorites- Save label picture• Spoiler alert- I have done next to nothing to style the app
  16. 16. Sketch It OutIt’s a lot cheaper and faster to iterate at thislevel than in code
  17. 17. What Tools Did I Choose• Bundler - Simplify dependencies• ProMotion - Screen development and workflow• Formotion - Entry/edit forms• MotionModel - Models and relations• Teacup - Styling DSL• Sugarcube - UI extensions• BubbleWrap - I used it for camera, but lots more(JSON, HTTP, RSS, Location, Audio, Video)• MotionAwesome - Buttons and iconsMore at
  18. 18. ProMotion• Simplifies screen development• Support for table screens- Easily search for table entries• Helpers for tab and navbar controllers
  19. 19. Formotion• Easily create formsfor entry/edit• Integrates withProMotion• Support For- text- dates- sliders- check boxes- and many more
  20. 20. MotionModel• Wanted something like ActiveRecord• Chose MotionModel gem- Lightweight- Feels Railsy‣ Validations‣ ActiveRecord-like syntax‣ Relations- Serialization / deserialization support- Actively maintained- Formotion support(turned out not to matter)
  21. 21. Teacup• Layout and styleyour app in a DSL• Frees you up fromlayout of screens inXCode• Allows you to keepyour views a lotcleaner• Hierarchical andsupports variables
  22. 22. Sugarcube• Tons of helpful ‘syntactic sugar’ extensionsto make your development easier- conversion of hex color codes to UIColor- alert and action dialogs- symbol to iOS, e.g.,‣ :touch.uicontrolevent becomes UIControlEventTouchUpInside- array helpers- hash to object conversions
  23. 23. BubbleWrap• Amazing set of tools for- HTTP- JSON- RSS- Camera- Location- Alert boxes- REPL support• Just using it for the camera in my app
  24. 24. MotionAwesome• Great set of icons and buttons• Based on FontAwesome• So far only used it to create a camerabutton using a camera icon
  25. 25. Deploying to Device• Must be in Apple Developer Program- $99/year• Get provisioning and developercertificates• Deploy using rake- rake device- Make sure to quit iTunes and Image Capture• Can’t do some things with simulator- e.g. Camera
  26. 26. Where Do I Go Next• Better use of views and subviews- As app evolves will have more commoncontrols/groups -> re-use- Easier to lay out due to relative positioningused in subviews• Better/more styling- Will require more understanding of iOS• Persist images to file system• Do more with models- Averages, filtering, etc
  27. 27. Where Do I Go Next• Testing- This was very much a spike, but as the appevolves want to incorporate more automatedtesting- Tested the models, especially persistence andvalidation since these were areas of risk- Want to look at more integration testing‣ motion-frank (maintained by Cyrus Innovation)‣ motion-calabash
  28. 28. Questions I Still Have• ProMotion is awesome, but I wonder ifdown the road this paints me into acorner• Wild West of gems- Will be interesting to see what ideas andtools rise to the top• How much iOS should I learn- Interface Builder- CoreData
  29. 29. Resources• RubyMotion Developer Center-• RubyMotion by Clay Allsop-• iOS Dev Center- Tons of useful info, navigation is horrible-• RubyMotion Wrappers and Libraries-
  30. 30. Questions• Q&A
  31. 31. RoR to RubyMotionWriting Your First iOS AppMichael DenomyBostonMotion User GroupJune 25, 2013