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

What's New in RubyMotion 4

What's New in RubyMotion 4

Presentation given at RubyConf China 2015:

Laurent Sansonetti

October 10, 2015
Tweet

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. 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
  4. iOS CoreOS CoreServices Media Cocoa Touch Kernel, BSD, userland Foundation,

    Networking, CoreData, CoreLocation… Graphics (UIKit), Audio, Video… AddressBook, GameKit, MapKit…
  5. Android Linux Core Libraries Java Development Kit Application Frameworks Drivers

    OpenGL, SQLite, WebKit, libc… Core Java classes Android classes
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. Creating a new project $ motion create --template=ios Hello $

    motion create —-template=android Hello $ motion create --template=osx Hello
  12. Project configuration $ vi Rakefile Motion::Project::App.setup do |app| # Use

    `rake config' to see complete project settings. app.name = 'Hello' end
  13. Running $ rake $ rake simulator $ rake $ rake

    emulator iOS Simulator Android Emulator $ rake device iOS/Android Device
  14. # 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
  15. iOS

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

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