What's New in RubyMotion 4

What's New in RubyMotion 4

Presentation given at RubyConf China 2015:

935b9d1a50dd855aba577e69f4a59fdf?s=128

Laurent Sansonetti

October 10, 2015
Tweet

Transcript

  1. 2.
  2. 7.
  3. 13.
  4. 19.
  5. 23.
  6. 37.

    0% 23% 45% 68% 90% Q1 2012 Q1 2013 Q1

    2014 Q1 2015 78% 81,2% 75,5% 59,2% 18,3% 15,2% 16,9% 22,9% iOS Android Smartphones market Share in Unit Shipments Source: © IDC 2015
  7. 41.

    Web-based apps Native apps Easy to get started Hard to

    get started Can’t access platform features naturally Full access to platform features Low performance High performance Hard to provide good user experience Easy to provide good user experience
  8. 42.

    Web-based apps Native apps Easy to get started Hard to

    get started Can’t access platform features naturally Full access to platform features Low performance High performance Hard to provide good user experience Easy to provide good user experience
  9. 44.
  10. 50.

    iOS CoreOS CoreServices Media Cocoa Touch Kernel, BSD, userland Foundation,

    Networking, CoreData, CoreLocation… Graphics (UIKit), Audio, Video… AddressBook, GameKit, MapKit…
  11. 52.
  12. 54.

    Android Linux Core Libraries Java Development Kit Application Frameworks Drivers

    OpenGL, SQLite, WebKit, libc… Core Java classes Android classes
  13. 70.

    iOS Hello World class AppDelegate def application(application, didFinishLaunchingWithOptions:options) label =

    UILabel.new label.text = "Hello World!" label.sizeToFit viewController = UIViewController.new viewController.view.backgroundColor = UIColor.whiteColor label.center = viewController.view.center viewController.view.addSubview(label) frame = UIScreen.mainScreen.applicationFrame @window = UIWindow.alloc.initWithFrame(frame) @window.rootViewController = viewController @window.makeKeyAndVisible true end end
  14. 71.

    iOS Hello World class AppDelegate def application(application, didFinishLaunchingWithOptions:options) label =

    UILabel.new label.text = "Hello World!" label.sizeToFit viewController = UIViewController.new viewController.view.backgroundColor = UIColor.whiteColor label.center = viewController.view.center viewController.view.addSubview(label) frame = UIScreen.mainScreen.applicationFrame @window = UIWindow.alloc.initWithFrame(frame) @window.rootViewController = viewController @window.makeKeyAndVisible true end end
  15. 72.

    Android Hello World class MainActivity < Android::App::Activity def onCreate(savedInstanceState) super

    text = Android::Widget::TextView.new(self) text.text = 'Hello RubyMotion!' self.contentView = text end end
  16. 73.

    Android Hello World class MainActivity < Android::App::Activity def onCreate(savedInstanceState) super

    text = Android::Widget::TextView.new(self) text.text = 'Hello RubyMotion!' self.contentView = text end end
  17. 76.

    Static compilation • RubyMotion apps are native binaries • For

    iOS: a native executable • For Android: a JNI native library • The original Ruby source code is not present in the application bundle • RubyMotion apps weight a couple MB
  18. 77.
  19. 79.
  20. 80.

    Creating a new project $ motion create --template=ios Hello $

    motion create —-template=android Hello $ motion create --template=osx Hello
  21. 81.

    Project configuration $ vi Rakefile Motion::Project::App.setup do |app| # Use

    `rake config' to see complete project settings. app.name = 'Hello' end
  22. 82.

    Running $ rake $ rake simulator $ rake $ rake

    emulator iOS Simulator Android Emulator $ rake device iOS/Android Device
  23. 84.
  24. 85.
  25. 86.
  26. 87.
  27. 88.
  28. 89.
  29. 91.
  30. 98.

    # app/app_delegate.rb class AppDelegate < PM::Delegate status_bar true, animation: :fade

    def on_load(app, options) open RootScreen end end # app/screens/root_screen.rb class RootScreen < PM::Screen title "Root Screen" nav_bar true def on_load set_nav_bar_button :right, title: “Help", action: :open_help_screen end def open_help_screen open HelpScreen end end
  31. 102.
  32. 103.
  33. 108.

    iOS

  34. 113.
  35. 122.
  36. 128.
  37. 133.
  38. 134.
  39. 138.
  40. 143.
  41. 145.
  42. 149.
  43. 164.
  44. 165.
  45. 166.
  46. 169.
  47. 170.
  48. 178.
  49. 181.
  50. 182.

    RubyMotion ♥ China • Weibo account (for announcements) • Local

    server (faster download) • Chinese forum • … and other things… stay tuned!