RubyMotion
Programming OS X and iOS apps with Ruby
Hi
I’m @MarkVillacampa
MacRuby
Started by Laurent Sansonetti inside Apple
Initial 0.1 release in March 2008
Goal: Write OS X applications in Ruby...
MacRuby
An implementation of the Ruby language that
runs on top of the Objective-C runtime and
garbage collection
Based on...
RubyMotion
Commercial product.
Write OS X and iOS applications using Ruby
Laurent Sansonetti left Apple to work on it.
Rel...
RubyMotion
Built on top of MacRuby
Uses a new LLVM-based static compiler that
generates optimized machine code
Memory mode...
Cocoa
Apple's native object-oriented API for OS X
and iOS
Includes a lot of different libraries
Very mature (originally de...
Key concepts:
RubyMotion objects are Objective-C objects
>> "Hello Betabeers!".class.ancestors
=> [String, NSMutableString...
Key concepts:
Can use Ruby & Cocoa methods
>> "Hello Madridrb!".upcase ← Ruby
=> "HELLO MADRIDRB!"
>> "Hello Madridrb!".up...
Key concepts:
New method syntax: named parameters
>> NSDictionary.alloc.initWithObjects(["foo"], forKeys:
["bar"])
=> {"fo...
1. The syntax
Objective-C:
Ruby:
a = {"foo" => ["bar", "baz"], "oof" => 2}
NSMutableDictionary *dict = [NSMutableDictionary dictionary];...
2. No Xcode
HelloMadridrb
app
app_delegate.rb
resources
spec
main_spec.rb
.gitignore
Rakefile
$ motion create MotionBetabeers
.rb files
...
3. Gems
http://rubymotion-wrappers.com
Can't use CRuby gems ('require' is not allowed)
Many wrappers and libraries specifically cre...
4. TDD
Bacon
http://www.rubymotion.com/developer-center/articles/testing/
Rspec syntax
Helpers to test touch UI in iOS
describe "...
6. Interactive Console
(REPL)
Holding and clicking in a
UI element assigns that
element to the self variable in
the console
7. CocoaPods
CocoaPods is like RubyGems but for Ojective-C
projects.
$ sudo gem install cocoapods
$ pod setup
$ sudo gem install motion...
8. Production Ready
http://www.rubymotion.com/apps/
Hundreds of apps in the AppStore
Used at Cabify since 2012
http://www.rubymotion.com/developer-center/
Thanks
www.markvillacampa.com
Twitter: @MarkVillacampa
RubyMotion
RubyMotion
Upcoming SlideShare
Loading in …5
×

RubyMotion

326 views

Published on

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
326
On SlideShare
0
From Embeds
0
Number of Embeds
23
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

RubyMotion

  1. 1. RubyMotion Programming OS X and iOS apps with Ruby
  2. 2. Hi I’m @MarkVillacampa
  3. 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. 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. 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. 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. 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. 8. Key concepts: RubyMotion objects are Objective-C objects >> "Hello Betabeers!".class.ancestors => [String, NSMutableString, NSString, Comparable, NSObject, Kernel]
  9. 9. Key concepts: Can use Ruby & Cocoa methods >> "Hello Madridrb!".upcase ← Ruby => "HELLO MADRIDRB!" >> "Hello Madridrb!".uppercaseString ← Cocoa => "HELLO MADRIDRB!"
  10. 10. Key concepts: New method syntax: named parameters >> NSDictionary.alloc.initWithObjects(["foo"], forKeys: ["bar"]) => {"foo"=>"bar"}
  11. 11. 1. The syntax
  12. 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. 13. 2. No Xcode
  14. 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. 15. 3. Gems
  16. 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. 17. 4. TDD
  18. 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. 19. 6. Interactive Console (REPL)
  20. 20. Holding and clicking in a UI element assigns that element to the self variable in the console
  21. 21. 7. CocoaPods
  22. 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. 23. 8. Production Ready
  24. 24. http://www.rubymotion.com/apps/ Hundreds of apps in the AppStore Used at Cabify since 2012
  25. 25. http://www.rubymotion.com/developer-center/
  26. 26. Thanks www.markvillacampa.com Twitter: @MarkVillacampa

×