Your SlideShare is downloading. ×

RubyMotion

119

Published on

Charla sobre RubyMotion por Marcos Villacampa, Betabeers Madrid 23/05/2014

Charla sobre RubyMotion por Marcos Villacampa, Betabeers Madrid 23/05/2014

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
119
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. RubyMotion Programming OS X and iOS apps with Ruby
  • 2. Hi I’m @MarkVillacampa
  • 3. MacRuby Started by Laurent Sansonetti inside Apple Initial 0.1 release in March 2008 Goal: Write OS X applications in Ruby without any performance loss
  • 4. MacRuby An implementation of the Ruby language that runs on top of the Objective-C runtime and garbage collection Based on Ruby 1.9 Uses LLVM Eventually "sunsetted" by Apple :(
  • 5. RubyMotion Commercial product. Write OS X and iOS applications using Ruby Laurent Sansonetti left Apple to work on it. Released May 3rd, 2012 Awesome community!
  • 6. RubyMotion Built on top of MacRuby Uses a new LLVM-based static compiler that generates optimized machine code Memory model similar to Objective-C ARC Based on Rake http://www.rubymotion.com/
  • 7. Cocoa Apple's native object-oriented API for OS X and iOS Includes a lot of different libraries Very mature (originally developed at NeXTSTEP in the 80s)
  • 8. Key concepts: RubyMotion objects are Objective-C objects >> "Hello Betabeers!".class.ancestors => [String, NSMutableString, NSString, Comparable, NSObject, Kernel]
  • 9. Key concepts: Can use Ruby & Cocoa methods >> "Hello Madridrb!".upcase ← Ruby => "HELLO MADRIDRB!" >> "Hello Madridrb!".uppercaseString ← Cocoa => "HELLO MADRIDRB!"
  • 10. Key concepts: New method syntax: named parameters >> NSDictionary.alloc.initWithObjects(["foo"], forKeys: ["bar"]) => {"foo"=>"bar"}
  • 11. 1. The syntax
  • 12. Objective-C: Ruby: a = {"foo" => ["bar", "baz"], "oof" => 2} NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSArray arrayWithObjects:@"bar", @"baz"] forKey:@"foo"]; [dict setObject:[NSNumber numberWithInt:2] forKey:@"oof"];
  • 13. 2. No Xcode
  • 14. HelloMadridrb app app_delegate.rb resources spec main_spec.rb .gitignore Rakefile $ motion create MotionBetabeers .rb files Main delegate Images, Sounds, .xib files Tests Configuration file
  • 15. 3. Gems
  • 16. http://rubymotion-wrappers.com Can't use CRuby gems ('require' is not allowed) Many wrappers and libraries specifically created for Rubymotion and Cocoa: https://github.com/rubymotion/motion-kit E.g.: Motion-Kit
  • 17. 4. TDD
  • 18. Bacon http://www.rubymotion.com/developer-center/articles/testing/ Rspec syntax Helpers to test touch UI in iOS describe "Application" do before do @app = UIApplication.sharedApplication end ! it "has one window" do @app.windows.size.should == 1 end end
  • 19. 6. Interactive Console (REPL)
  • 20. Holding and clicking in a UI element assigns that element to the self variable in the console
  • 21. 7. CocoaPods
  • 22. CocoaPods is like RubyGems but for Ojective-C projects. $ sudo gem install cocoapods $ pod setup $ sudo gem install motion-cocoapods Choose a pod:
 https://github.com/CocoaPods/Specs Edit Rakefile: require 'motion-cocoapods' ! Motion::Project::App.setup do |app| # ... app.pods do dependency 'Facebook-iOS-SDK' end end
  • 23. 8. Production Ready
  • 24. http://www.rubymotion.com/apps/ Hundreds of apps in the AppStore Used at Cabify since 2012
  • 25. http://www.rubymotion.com/developer-center/
  • 26. Thanks www.markvillacampa.com Twitter: @MarkVillacampa

×