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. RubyMotion It’s about time!

  2. 您好!

  3. ⼤大家好,我是Laurent。 可是我还不会讲中⽂文。

  4. ⾮非常抱歉!

  5. This presentation is not in Chinese!

  6. ! Simplified Traditional "

  7. Hello!

  8. Good evening!

  9. Last presentation of the day!

  10. I worked on this presentation yesterday from my hotel room

  11. This presentation is

  12. This presentation is

  13. Sorry!

  14. Myself • Laurent Sansonetti • Software hacker • Company founder

    50% Business 50% Programming
  15. Ruby programmer since 2002

  16. Apple 2004-2012

  17. HipByte 2012-now RubyMotion

  18. From Belgium

  19. None
  20. Sooooo small!

  21. 314x smaller than China

  22. 114x less people than China

  23. But!

  24. 18x more beer breweries than China!

  25. ruby_boulets.rb Ruby user group meetup in Liège, Belgium Please come!

  26. ruby_boulets.rb Ruby user group meetup in Liège, Belgium Please come!

  27. orval.club An association of people who strongly believe that Orval

    is the best beer of the world
  28. orval.club An association of people who strongly believe that Orval

    is the best beer of the world
  29. Thank you! • Ruby China • Chunlea Ju

  30. Agenda • RubyMotion • Let’s write apps • Questions

  31. RubyMotion

  32. Mobile development using Ruby

  33. State of mobile development

  34. Two platforms

  35. iOS and Android

  36. iOS Android

  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
  38. Going iOS-only is no longer possible

  39. You need to go cross-platform

  40. You need to go native as well

  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
  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
  43. Native apps provide the best UX

  44. None
  45. Consumers want the best UX

  46. Native apps are harder to make, but consumers don’t care

    about this
  47. Customer > Programmer

  48. Platforms architectures

  49. iOS CoreOS CoreServices Media Cocoa Touch

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

    Networking, CoreData, CoreLocation… Graphics (UIKit), Audio, Video… AddressBook, GameKit, MapKit…
  51. iOS CoreOS CoreServices Media Cocoa Touch }C / Objective-C

  52. Xcode IDE

  53. Android Linux Core Libraries Java Development Kit Application Frameworks

  54. Android Linux Core Libraries Java Development Kit Application Frameworks Drivers

    OpenGL, SQLite, WebKit, libc… Core Java classes Android classes
  55. Android Linux Core Libraries Java Development Kit Application Frameworks }Java

  56. Android Studio IDE

  57. iOS Android Language Objective-C Swift Java Environment Xcode Android Studio

    APIs iOS SDK Android SDK Native development
  58. Can we make this simpler?

  59. RubyMotion

  60. Toolchain to write native mobile apps in Ruby

  61. Cross-platform: iOS and Android (and OS X)

  62. Designed for Ruby programmers

  63. Consistent experience for cross-platform native development

  64. iOS Android Language Objective-C Swift Java Environment Xcode Android Studio

    APIs iOS SDK Android SDK
  65. iOS Android Language Ruby Environment Your Editor + Terminal APIs

    iOS SDK Android SDK
  66. Unified Ruby runtimes

  67. Custom implementations of the Ruby language for each platform

  68. RubyMotion iOS SDK Objective-C Objective-C Runtime iOS

  69. RubyMotion Android SDK Java Dalvik / ART JNI Android

  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
  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
  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
  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
  74. Static compilation

  75. Compilation Ruby File AST LLVM IR Assembly (ARM or Intel)

    Runtime
  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
  77. None
  78. Command-line interface

  79. None
  80. Creating a new project $ motion create --template=ios Hello $

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

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

    emulator iOS Simulator Android Emulator $ rake device iOS/Android Device
  83. Distribution $ rake archive:distribution #=> foo.ipa $ rake release #=>

    foo.apk iOS App Store Android Play Store
  84. None
  85. None
  86. None
  87. None
  88. None
  89. None
  90. https://www.jetbrains.com/ ruby/rubymotion

  91. Gems

  92. Ruby DSLs over iOS/Android APIs

  93. Cross-platform

  94. iOS Android

  95. “Rails of RubyMotion”

  96. Write app almost in pure Ruby

  97. Appeal to Rails developers

  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
  99. BREAKING NEWS

  100. RubyMotion Starter

  101. Free version of RubyMotion

  102. Free?

  103. Free?

  104. Free as in beer

  105. Fully-featured (iOS and Android)

  106. Splash screen

  107. rubymotion.com/download

  108. iOS

  109. Stable iOS 9.0 Xcode 7 Beta iOS 9.1 Xcode 7.1

  110. All supported by RubyMotion

  111. RubyMotion supports new versions of iOS less than 24 hours

    after release
  112. rubymotion.com/download

  113. Android M

  114. Android 6.0

  115. API level 23

  116. app.api_version = "23"

  117. RubyMotion supports new versions of Android less than 24 hours

    after release
  118. rubymotion.com/download

  119. watchOS 2.0

  120. Native SDK for Watch

  121. Runs on Content watchOS 1.0 iPhone (connected) View-only watchOS 2.0

    Apple Watch Code (APIs)
  122. None
  123. rubymotion.com/download

  124. motion-game

  125. Create games for iOS and Android

  126. Cross-platform Ruby API to write games

  127. Fully-featured Scene Graph Sensor Events Sprites Animations Physics Particles Parallax

    Networking UI Widgets
  128. None
  129. One code base ↓ iOS and Android

  130. 100% cross-platform

  131. rubymotion.com/download

  132. gem install motion-game

  133. iPad Pro

  134. None
  135. Same as regular iPad development (iOS)

  136. rubymotion.com/download

  137. OS X El Capitan

  138. OS X 10.11

  139. Supported in RubyMotion since WWDC

  140. Use RubyMotion on El Capitan

  141. Write El Capitan native apps in RubyMotion

  142. rubymotion.com/download

  143. tvOS

  144. Native SDK for TV

  145. None
  146. TV now runs iOS

  147. You can write apps for TV

  148. You can write games for TV

  149. None
  150. Announced in mid-September

  151. Supported in RubyMotion 2 weeks after!

  152. arm64-based iOS SDK Simulator New frameworks

  153. rubymotion.com/download (currently in beta)

  154. Please download RubyMotion!

  155. It’s freeeeeeeee!

  156. rubymotion.com/download

  157. Now, let’s write apps!

  158. #1: boring app

  159. Let’s write an app that shows the best beers of

    the world
  160. Best beers of the world?

  161. Trappist beers

  162. Made by Cistercian monks

  163. https://en.wikipedia.org/ wiki/Trappist_beer

  164. None
  165. None
  166. None
  167. #2: fun app

  168. Let’s write a video game!

  169. None
  170. Conclusion

  171. RubyMotion lets you write cross-platform mobile apps

  172. … and games!

  173. True native apps

  174. Use all platform APIs at no performance expense

  175. Statically compiled

  176. Use cross-platform gems

  177. One language

  178. Ruby

  179. One interface

  180. Your terminal and your favorite editor

  181. None
  182. RubyMotion ♥ China • Weibo account (for announcements) • Local

    server (faster download) • Chinese forum • … and other things… stay tuned!
  183. rubymotion.com/download

  184. 谢谢 @rubymotion (Twitter, Weibo (soon)) www.rubymotion.com We have stickers! Please

    come and grab one!