47
RubyConf Taiwan RubyMotion Gets A Cool New Friend mruby on iOS

RubyMotion Gets A Cool New Friend: mruby on iOS

Embed Size (px)

Citation preview

Page 1: RubyMotion Gets A Cool New Friend: mruby on iOS

Ruby

Conf

Taiwan

RubyMotion Gets A Cool New Friend

mruby on iOS

Page 2: RubyMotion Gets A Cool New Friend: mruby on iOS

Who Am I?

Page 3: RubyMotion Gets A Cool New Friend: mruby on iOS

古傑芳

Page 4: RubyMotion Gets A Cool New Friend: mruby on iOS

@josephku

Page 5: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 6: RubyMotion Gets A Cool New Friend: mruby on iOS

!WHAT’S RUBYMOTION?

A Ruby toolchain for iOS

Develop and test native iOS app in Ruby

Based on MacRuby

Page 7: RubyMotion Gets A Cool New Friend: mruby on iOS

Objective-C

Objective-C Runtime

iOS SDK

Foundation Framework

Page 8: RubyMotion Gets A Cool New Friend: mruby on iOS

Objective-C

Objective-C Runtime

iOS SDK

Foundation Framework

RubyMotion

Page 9: RubyMotion Gets A Cool New Friend: mruby on iOS

!WHY RUBYMOTION?

100% native code

Keep your editor

App Store compliant

Page 10: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 11: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 12: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 13: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 14: RubyMotion Gets A Cool New Friend: mruby on iOS

!DEPLOYMENT

Deploy your app to beta testers by TestFlight

!

!

Deploy to App Store

$ rake archive:distribution

$ gem install motion-testflight

$ rake testflight notes='Orz'

Page 15: RubyMotion Gets A Cool New Friend: mruby on iOS

!UPDATES FOR RUBYMOTION

Xcode 5.1 & iOS 7.1 support

OS X support

Templates

Fix tons of memory management issues

Background fetching

Performance improvements

Page 17: RubyMotion Gets A Cool New Friend: mruby on iOS

Super aggressive team!

Page 18: RubyMotion Gets A Cool New Friend: mruby on iOS

Babe, Let’s Rock!!

Page 19: RubyMotion Gets A Cool New Friend: mruby on iOS

class Test def test foo = 42 Proc.new { foo + 123 } endend!Test.new.test.call # Crashes sometimes

Page 20: RubyMotion Gets A Cool New Friend: mruby on iOS

mruby

1.0.0

Page 21: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 22: RubyMotion Gets A Cool New Friend: mruby on iOS

How about mruby on Apple’s 64-bit A7 SoC?

Page 23: RubyMotion Gets A Cool New Friend: mruby on iOS

app.archs['iPhoneOS'] << 'arm64'

RubyMotion - Rakefile

Page 24: RubyMotion Gets A Cool New Friend: mruby on iOS

MRuby::CrossBuild.new('ios-arm64') do |conf| toolchain :gcc! conf.cc.flags << "-arch arm64" conf.linker.flags << "-arch arm64” # ... !end

mruby - build_config.rb

Page 25: RubyMotion Gets A Cool New Friend: mruby on iOS

#define MRB_INT64

Page 26: RubyMotion Gets A Cool New Friend: mruby on iOS

#define MRB_USE_FLOAT

Page 27: RubyMotion Gets A Cool New Friend: mruby on iOS

#define MRB_USE_FLOAT; #define MRB_INT64

0%

1%

2%

3%

4%

5%

6%

bm_so_lists.rb fib39.rb

Benchmark on A7

Page 28: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 29: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 30: RubyMotion Gets A Cool New Friend: mruby on iOS

64-bit RiteVM

Page 31: RubyMotion Gets A Cool New Friend: mruby on iOS

!WHY MRUBY & RUBYMOTION?

Focusing

Avoiding limitations

Page 32: RubyMotion Gets A Cool New Friend: mruby on iOS

DSL

Page 33: RubyMotion Gets A Cool New Friend: mruby on iOS

mruby + RubyMotion = ?

Page 34: RubyMotion Gets A Cool New Friend: mruby on iOS

Where to use?

Page 35: RubyMotion Gets A Cool New Friend: mruby on iOS

Explain things better

Page 36: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 37: RubyMotion Gets A Cool New Friend: mruby on iOS

{ "uuid": "B9407F30-F5F8-466E-AFF9-25556B57FE6D", "events": [ { "proximity": "immediate", "url": "http://host.com/event/1" }, { "proximity": "near", "url": "http://host.com/event/2" }, { "proximity": "far", "url": "http://host.com/event/3" } ]}

Page 38: RubyMotion Gets A Cool New Friend: mruby on iOS
Page 39: RubyMotion Gets A Cool New Friend: mruby on iOS

beacon b1 do uuid "B9407F30-F5F8-466E-AFF9-25556B57FE6D" major 75682 minor 1end!beacon b2 do uuid "B9407F30-F5F8-466E-AFF9-25556B57FE6D" major 75682 minor 2end!beacon b3 do uuid "B9407F30-F5F8-466E-AFF9-25556B57FE6D" major 75682 minor 3end!event b1.far, b2.near do url “https://host.com/event/1"end!event b2.immediate, !b3.far do url “https://host.com/event/2"end

Page 40: RubyMotion Gets A Cool New Friend: mruby on iOS

Game scripting in mruby

Page 41: RubyMotion Gets A Cool New Friend: mruby on iOS

Lua! Ruby!

Page 42: RubyMotion Gets A Cool New Friend: mruby on iOS

Babe, Let’s Rock!!

Page 43: RubyMotion Gets A Cool New Friend: mruby on iOS

Hide your code

Page 44: RubyMotion Gets A Cool New Friend: mruby on iOS

#include <stdint.h>const uint8_t nothing_here[] = {0x52,0x49,0x54,0x45,0x30,0x30,0x30,0x32,0x1f,0xef,0x00,0x00,0x00,0x62,0x4d,0x41,0x54,0x5a,0x30,0x30,0x30,0x30,0x49,0x52,0x45,0x50,0x00,0x00,0x00,0x44,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x38,0x00,0x01,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x80,0x00,0x06,0x01,0x00,0x00,0x3d,0x00,0x80,0x00,0xa0,0x00,0x00,0x00,0x4a,0x00,0x00,0x00,0x01,0x00,0x00,0x08,0x74,0x6f,0x6c,0x64,0x20,0x79,0x6f,0x75,0x00,0x00,0x00,0x01,0x00,0x04,0x70,0x75,0x74,0x73,0x00,0x45,0x4e,0x44,0x00,0x00,0x00,0x00,0x08,};

secret.c

$ mrbc -Bnothing_here secret.rb

mrb.read_irep nothing_heremrb.run

Page 45: RubyMotion Gets A Cool New Friend: mruby on iOS

Ruby Everywhere!!

Page 46: RubyMotion Gets A Cool New Friend: mruby on iOS

Any questions?

Page 47: RubyMotion Gets A Cool New Friend: mruby on iOS

Thank you!