Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RubyMotion: Rubyizing iOS development

Amit Kumar
September 15, 2012

RubyMotion: Rubyizing iOS development

Amit Kumar

September 15, 2012
Tweet

More Decks by Amit Kumar

Other Decks in Technology

Transcript

  1. About me • Ruby’ist • Consultant: Tata Consultancy Services Ltd

    • Github: toamitkumar • Twitter: toamit • toamitkumar.github.com Sunday, September 16, 12
  2. revolutionary toolchain for native iOS application development using Ruby language

    neighbor's envy coder’s delight; happiness; RubyMotion Sunday, September 16, 12
  3. Fork of MacRuby Automatic object memory allocation and reclaim A

    What ?? Compiles into optimized machine code Sunday, September 16, 12
  4. Fork of MacRuby Automatic object memory allocation and reclaim A

    What ?? Compiles into optimized machine code Sunday, September 16, 12
  5. Fork of MacRuby Automatic object memory allocation and reclaim A

    What ?? Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12
  6. Fork of MacRuby Automatic object memory allocation and reclaim A

    What ?? Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12
  7. Ruby-runtime tightly integrated with Obj-C runtime Fork of MacRuby Automatic

    object memory allocation and reclaim A What ?? Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12
  8. Ruby-runtime tightly integrated with Obj-C runtime Fork of MacRuby Automatic

    object memory allocation and reclaim A What ?? Same ancestor as Obj-C Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12
  9. A What ?? Ruby-runtime tightly integrated with Obj-C runtime Fork

    of MacRuby Automatic object memory allocation and reclaim Same ancestor as Obj-C Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12
  10. A What ?? Object can be shared with no performance

    cost Ruby-runtime tightly integrated with Obj-C runtime Fork of MacRuby Automatic object memory allocation and reclaim Same ancestor as Obj-C Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12
  11. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? Sunday, September 16, 12
  12. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Sunday, September 16, 12
  13. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: Sunday, September 16, 12
  14. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Sunday, September 16, 12
  15. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: Sunday, September 16, 12
  16. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: - Its a bridge that makes native api calls Sunday, September 16, 12
  17. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: - Its a bridge that makes native api calls - Runs in single thread of UIWebView which is painfully slow Sunday, September 16, 12
  18. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: - Its a bridge that makes native api calls - Runs in single thread of UIWebView which is painfully slow - Limited support of direct access to native APIs Sunday, September 16, 12
  19. Myths Can I code using RubyMotion without the pain to

    learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: - Its a bridge that makes native api calls - Runs in single thread of UIWebView which is painfully slow - Limited support of direct access to native APIs - Debugging becomes extremely difficult when you make native api calls Sunday, September 16, 12
  20. The ‘motion’ command Protip: Forcing update to a particular version:

    sudo motion update --force-version=1.2 Sunday, September 16, 12
  21. The Soul Console REPL - Read Evaluate Print Loop You

    feel in-control Sunday, September 16, 12
  22. The Soul Console REPL - Read Evaluate Print Loop You

    feel in-control Sunday, September 16, 12
  23. The Soul Console REPL - Read Evaluate Print Loop You

    feel in-control An excellent in-browser demo of REPL: https://www.pieceable.com/rubymotion-console Sunday, September 16, 12
  24. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ Sunday, September 16, 12
  25. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb Sunday, September 16, 12
  26. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec Sunday, September 16, 12
  27. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: Sunday, September 16, 12
  28. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions Sunday, September 16, 12
  29. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers Sunday, September 16, 12
  30. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers - before/after blocks Sunday, September 16, 12
  31. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers - before/after blocks View testing: Sunday, September 16, 12
  32. Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’

    like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers - before/after blocks View testing: - Loading the nib/xib/storyboard file Sunday, September 16, 12
  33. Continuos Integration WebHook Jenkins setup on mac-mini App Store Push

    Setup for local deployment and testing Sunday, September 16, 12
  34. RubyGems Normal RubyGems won’t work Use Bundler source :rubygems gem

    'rake' gem 'bubble-wrap' gem 'motion-cocoapods' gem 'motion-redgreen' Gemfile require ‘bundler’ Bundler.require Rakefile Motion::Project::App.setup do |app| # Load files from gem end Sunday, September 16, 12
  35. Statically Compiled app.vendor_project( “vendor/project-name”, #should have both .h and .m

    file :static ) Using Obj-C code XCode project: app.vendor_project( “vendor/project-name”, :xcode, :xcodeproj => “project-name.xcodeproj”, :target => “project-name”, :products => [“libproject-name.a”], :headers_dir => “project-name” ) Sunday, September 16, 12
  36. Using native C code Basic Types in C (bool, char,

    int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) Sunday, September 16, 12
  37. Using native C code Basic Types in C (bool, char,

    int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) C Complex Data Structures Sunday, September 16, 12
  38. Using native C code Basic Types in C (bool, char,

    int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) C Complex Data Structures No corresponding Ruby Data Types Sunday, September 16, 12
  39. Using native C code Basic Types in C (bool, char,

    int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) C Complex Data Structures No corresponding Ruby Data Types Sunday, September 16, 12
  40. Using native C code Basic Types in C (bool, char,

    int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) BridgeSupport C Complex Data Structures No corresponding Ruby Data Types Sunday, September 16, 12
  41. Using native C code Basic Types in C (bool, char,

    int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) RubyMotion BridgeSupport C Complex Data Structures No corresponding Ruby Data Types Sunday, September 16, 12
  42. CocoaPods is a dependency manager for Obj-C projects sudo gem

    install cocoapods Sunday, September 16, 12
  43. CocoaPods is a dependency manager for Obj-C projects sudo gem

    install cocoapods pod setup # this may not be required for everyone, it never worked for me Sunday, September 16, 12
  44. CocoaPods is a dependency manager for Obj-C projects sudo gem

    install cocoapods pod setup # this may not be required for everyone, it never worked for me https://github.com/CocoaPods/Specs - lists all the pods Sunday, September 16, 12
  45. CocoaPods is a dependency manager for Obj-C projects sudo gem

    install cocoapods pod setup # this may not be required for everyone, it never worked for me https://github.com/CocoaPods/Specs - lists all the pods It has been integrated with RubyMotion which comes as a gem Sunday, September 16, 12
  46. CocoaPods is a dependency manager for Obj-C projects sudo gem

    install cocoapods pod setup # this may not be required for everyone, it never worked for me https://github.com/CocoaPods/Specs - lists all the pods It has been integrated with RubyMotion which comes as a gem sudo gem install motion-cocoapods Sunday, September 16, 12
  47. CocoaPods is a dependency manager for Obj-C projects sudo gem

    install cocoapods pod setup # this may not be required for everyone, it never worked for me https://github.com/CocoaPods/Specs - lists all the pods It has been integrated with RubyMotion which comes as a gem sudo gem install motion-cocoapods Include it in your Rakefile: require  ‘moion-­‐cocoapods’ Motion::Project::App.setup  do  |app|    #  ...    app.pods  do        dependency  'JSONKit'        dependency  'iActiveRecord'    end   end Sunday, September 16, 12
  48. Long way to go ! RM is only ~4 months

    old Sunday, September 16, 12
  49. Long way to go ! RM is only ~4 months

    old Something it lacks: - Debugger (but REPL kind of makes it easy) - Some dynamic code doesn’t work (but hey !!!) Sunday, September 16, 12