RubyMotion Gets A Cool New Friend: mruby on iOS

Post on 15-May-2015

327 views 1 download

Transcript of RubyMotion Gets A Cool New Friend: mruby on iOS

Ruby

Conf

Taiwan

RubyMotion Gets A Cool New Friend

mruby on iOS

Who Am I?

古傑芳

@josephku

!WHAT’S RUBYMOTION?

A Ruby toolchain for iOS

Develop and test native iOS app in Ruby

Based on MacRuby

Objective-C

Objective-C Runtime

iOS SDK

Foundation Framework

Objective-C

Objective-C Runtime

iOS SDK

Foundation Framework

RubyMotion

!WHY RUBYMOTION?

100% native code

Keep your editor

App Store compliant

!DEPLOYMENT

Deploy your app to beta testers by TestFlight

!

!

Deploy to App Store

$ rake archive:distribution

$ gem install motion-testflight

$ rake testflight notes='Orz'

!UPDATES FOR RUBYMOTION

Xcode 5.1 & iOS 7.1 support

OS X support

Templates

Fix tons of memory management issues

Background fetching

Performance improvements

Super aggressive team!

Babe, Let’s Rock!!

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

mruby

1.0.0

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

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

RubyMotion - Rakefile

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

mruby - build_config.rb

#define MRB_INT64

#define MRB_USE_FLOAT

#define MRB_USE_FLOAT; #define MRB_INT64

0%

1%

2%

3%

4%

5%

6%

bm_so_lists.rb fib39.rb

Benchmark on A7

64-bit RiteVM

!WHY MRUBY & RUBYMOTION?

Focusing

Avoiding limitations

DSL

mruby + RubyMotion = ?

Where to use?

Explain things better

{ "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" } ]}

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

Game scripting in mruby

Lua! Ruby!

Babe, Let’s Rock!!

Hide your code

#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

Ruby Everywhere!!

Any questions?

Thank you!