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

RubyMotion 2.0

6e8aca910e7ee095397d3b90acb25f6c?s=47 Watson
May 29, 2013

RubyMotion 2.0

Presentation for RubyKaigi 2013

6e8aca910e7ee095397d3b90acb25f6c?s=128

Watson

May 29, 2013
Tweet

Transcript

  1. RubyMotion 2.0 Shizuo Fujita 13೥5݄30೔໦༵೔

  2. MacRuby 0.5 beta 13೥5݄30೔໦༵೔

  3. ͱʹ͔͘Ϋϥογϡʂ 13೥5݄30೔໦༵೔

  4. 13೥5݄30೔໦༵೔

  5. ͻͨ͢Βόάใࠂ 13೥5݄30೔໦༵೔

  6. macruby committer access? 13೥5݄30೔໦༵೔

  7. ຊ౰ʹܖ໿ॻΛॻ͍ͨ 13೥5݄30೔໦༵೔

  8. • MacRuby committer (2010೥8݄~) • Hipbyte (2012೥9݄~) Twitter : @watson1978

    Mail : watson1978@gmail.com 13೥5݄30೔໦༵೔
  9. 13೥5݄30೔໦༵೔

  10. RubyMotion 13೥5݄30೔໦༵೔

  11. class Member attr_accessor :name def say(message) puts "My name is

    #{name}" puts message end end 13೥5݄30೔໦༵೔
  12. @implementation Kaigi -(void)join:(NSString*)name { id klass = NSClassFromString(@"Member"); id member

    = [[klass alloc] init]; [member setName:name]; [member say:@"Hello, RubyMotion Kaigi!"]; } @end class Member attr_accessor :name def say(message) puts "My name is #{name}" puts message end end 13೥5݄30೔໦༵೔
  13. @implementation Kaigi -(void)join:(NSString*)name { id klass = NSClassFromString(@"Member"); id member

    = [[klass alloc] init]; [member setName:name]; [member say:@"Hello, RubyMotion Kaigi!"]; } @end Kaigi.new.join("Shizuo") class Member attr_accessor :name def say(message) puts "My name is #{name}" puts message end end 13೥5݄30೔໦༵೔
  14. 13೥5݄30೔໦༵೔

  15. 13೥5݄30೔໦༵೔

  16. • Ruby͔ΒObjective-CΛɺObjective-C͔ΒRubyΛ ௚઀ݺͼग़͢͜ͱͱ͕Ͱ͖Δ • RubyͱObjective-Cͷ΍ΓͱΓͰσʔλม׵ෆཁ • Ruby == Objective-C •

    ΫϥεɺϝιουɺΦϒδΣΫτ͢΂ͯ Objective-C • Objective-C runtime Λར༻͠RubyΛ࣮૷ 13೥5݄30೔໦༵೔
  17. # [bc, asm].each { |x| File.unlink(x) } arch_objs << arch_obj

    /Library/RubyMotion/lib/motion/project/builder.rb : 119 comment out 13೥5݄30೔໦༵೔
  18. # [bc, asm].each { |x| File.unlink(x) } arch_objs << arch_obj

    /Library/RubyMotion/lib/motion/project/builder.rb : 119 comment out LLVM தؒίʔυ ΞηϯϒϦ ./build/iPhoneXXX/objs/ ΦϒδΣΫτ 13೥5݄30೔໦༵೔
  19. 3VCZιʔε --7.தؒίʔυ ΞηϯϒϦϑΝΠϧ ΦϒδΣΫτϑΝΠϧ ࣮ߦϑΝΠϧ ϥΠϒϥϦ J04'SBNFXPSL ϕϯμʔTUBUJD ϥΠϒϥϦ ΞϓϦ

    13೥5݄30೔໦༵೔
  20. 3VCZιʔε --7.தؒίʔυ ΞηϯϒϦϑΝΠϧ ΦϒδΣΫτϑΝΠϧ ࣮ߦϑΝΠϧ ϥΠϒϥϦ J04'SBNFXPSL ϕϯμʔTUBUJD ϥΠϒϥϦ ΞϓϦ

    ωΠςΟϒʹϑϧίϯύΠϧ 13೥5݄30೔໦༵೔
  21. ΞϓϦέʔγϣϯ --7. ૊ࠐΈϥΠϒϥϦ 3VCZ7. "3$ϥΠΫͳ($ 'PVOEBUJPOγεςϜϥΠϒϥϦ J04 ($% Ϗϧυ γεςϜ

    13೥5݄30೔໦༵೔
  22. ΞϓϦέʔγϣϯ --7. ૊ࠐΈϥΠϒϥϦ 3VCZ7. "3$ϥΠΫͳ($ 'PVOEBUJPOγεςϜϥΠϒϥϦ 049 ($% 049༻ Ϗϧυ

    γεςϜ 13೥5݄30೔໦༵೔
  23. RubyMotion 2.0 • OS X Support • Project Template •

    Command-Line Plugin • Common Build Directory • Weak Reference 13೥5݄30೔໦༵೔
  24. OS X support (RubyMotion vs MacRuby) • ࣄલʹωΠςΟϒʹϑϧίϯύΠϧ • MacRuby

    ͸JITͰ࣮ߦ࣌ʹม׵ɺىಈʹ͕͔࣌ؒΔ • ελςΟοΫϥΠϒϥϦʔ͕࢖͑Δ • MacRuby ͸ίʔυमਖ਼ + OS X ͷ GC Λ༗ޮʹͯ͠ ίϯύΠϧඞཁ͕͋Δ • require ͱ evalɺඪ४ϥΠϒϥϦʔ͕࢖͑ͳ͍ ύϑΥʔϚϯε͕ 2ഒ͘Β͍ྑ͘ͳΔ 13೥5݄30೔໦༵೔
  25. Project Template 13೥5݄30೔໦༵೔

  26. Project Template • ϢʔβಠࣗͷςϯϓϨʔτ • ~/Library/RubyMotion/template/ ΁௥Ճ ௥Ճͨ͠ϑΝΠϧ 13೥5݄30೔໦༵೔

  27. Project Template • motion create --template=ςϯϓϨʔτ໊ ΞϓϦ໊ ࢀߟɿ/Library/RubyMotion/lib/motion/project/template ௥Ճͨ͠ϑΝΠϧ 13೥5݄30೔໦༵೔

  28. Command-Line Plugin • motion ίϚϯυͷશ͕ͯϓϥάΠϯԽ • account, activate, create,,,, 13೥5݄30೔໦༵೔

  29. Command-Line Plugin • ϢʔβಠࣗͷίϚϯυ • ~/Library/RubyMotion/command/ ΁௥Ճ ௥Ճͨ͠ϑΝΠϧ 13೥5݄30೔໦༵೔

  30. Command-Line Plugin ࢀߟɿ - /Library/RubyMotion/lib/motion/project/command - https://github.com/Watson1978/motion-doc ௥Ճͨ͠ίϚϯυ 13೥5݄30೔໦༵೔

  31. Common Build Directory 13೥5݄30೔໦༵೔

  32. Common Build Directory • rake clean ͢ΔͱશͯϏϧυ͠௚͠ • gem ϥΠϒϥϦ͸खΛՃ͑ͨΓ͠ͳ͍ͷͰɺҰ

    ౓ίϯύΠϧͨ͠Β࢖͍ճ͍ͨ͠ Ϗϧυͨ͠ϑΝΠϧ ֤ΞϓϦͰ࢖͍ճͤΔ΋ͷΛ ~/Library/RubyMotion/build ʹΩϟογϡ 13೥5݄30೔໦༵೔
  33. Weak Reference • ஋Λอ࣋͢Δ or ผͷϝιουͰར༻͢ΔͨΊʹɺ Πϯελϯεม਺ʹΦϒδΣΫτΛ֨ೲ → ڧࢀর •

    RubyMotion 1.xͰ͸ɺ • Πϯελϯεม਺Λհͨ͠ऑࢀর͕Ͱ͖·ͤΜͰͨ͠ 13೥5݄30೔໦༵೔
  34. Weak Reference class MyController def initialize(delegate) @delegate = delegate end

    def do_something # ... @delegate.did_something end end @delegateΛ࢖͍ऴΘͬͨޙɺ@delegateʹผͷΦϒδ ΣΫτ (nil౳) Λ֨ೲ͠ࢀরΛ੾Βͳ͍ͱɺ@delegate ͷࢀরݩΦϒδΣΫτ͕ղ์͞Εͳ͍ (॥؀ࢀর) 13೥5݄30೔໦༵೔
  35. Weak Reference class MyController def initialize(delegate) @delegate = WeakRef.new(delegate) end

    def do_something # ... @delegate.did_something end end WeakRef.new WeakRef.new Λ࢖ͬͯऑࢀরͰ͖ΔΑ͏ͳͬͨ 13೥5݄30೔໦༵೔
  36. Ruby४ڌ language core 94.21% 96.05% (with MacRuby, RubySpec) 13೥5݄30೔໦༵೔

  37. http://rubymotion.jp/ ೔ຊޠʹ༁ͨ͠υΩϡϝϯτ Λੋඇ͝Ұಡ͍ͩ͘͞ʂ 13೥5݄30೔໦༵೔