MacRuby & RubyMotion - Madridrb May 2012

1,845 views
1,760 views

Published on

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

No Downloads
Views
Total views
1,845
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
17
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

MacRuby & RubyMotion - Madridrb May 2012

  1. 1. MacRuby & RubyMotion Programming OS X and iOS apps with Ruby
  2. 2. HiI’m @MarkVillacampa
  3. 3. BlameHim
  4. 4. MacRubyAn implementation of the Ruby language thatruns on top of the Objective-C runtime andgarbage collection (libauto)Based on Ruby 1.9Uses LLVM and supports both ahead-of-timeand just-in-time compilationShips with OS X 10.7 Lion!!
  5. 5. MacRubyStarted by Laurent Sansonetti inside AppleInitial 0.1 release in March 2008Latest stable release (0.10) March 2011Nightlies are very stable (0.12)http://macruby.org/https://github.com/MacRuby/MacRuby
  6. 6. CocoaApples native object-oriented API for theMac OS X operating systemFoundation Kit + Application Kit + Core DataframeworksCocoa Touch: Includes gesture recognitionand different UI to use in iOS
  7. 7. How to installInstall XCode (Mac App Store, Free)Install Command Line Tools (Preferences >Downloads)Install MacRuby NightlyIf you are in OS X 10.6.8, install BridgeSupport Preview 3https://github.com/MacRuby/MacRuby/wiki/Setting-up-MacRuby
  8. 8. Key concepts: MacRuby objects are Objective-C objects>> "Hello Madridrb!".class.ancestors=> [String, NSMutableString, NSString, Comparable, NSObject,Kernel] Can use Ruby & Cocoa methods>> "Hello Madridrb!".upcase <- Ruby=> "HELLO MADRIDRB!">> "Hello Madridrb!".uppercaseString <- Cocoa=> "HELLO MADRIDRB!"
  9. 9. Key concepts: Cocoa classes need to be allocated and initialized>> NSString.alloc.initWithString(“Hello Madridrb!”)=> "Hello Madridrb!" New method syntax: named parameters>> NSDictionary.alloc.initWithObjects(["foo"], forKeys:["bar"])=> {"foo"=>"bar"}
  10. 10. 1. The syntax
  11. 11. Objective-C:NSMutableDictionary *dict = [NSMutableDictionary dictionary];[dict setObject:[NSArray arrayWithObjects:@"bar", @"baz"]forKey:@"foo"];[dict setObject:[NSNumber numberWithInt:2] forKey:@"oof"]; Ruby:a = {"foo" => ["bar", "baz"], "oof" => 2}
  12. 12. Objective-C:NSMutableDictionary *dict = [NSMutableDictionary dictionary];[dict setObject:[NSArray arrayWithObjects:@"bar", @"baz"]forKey:@"foo"];[dict setObject:[NSNumber numberWithInt:2] forKey:@"oof"]; Ruby:a = {"foo" => ["bar", "baz"], "oof" => 2}
  13. 13. 2. XCode
  14. 14. Interface Builder
  15. 15. 3. REPL Console ( Read Eval Print Loop )
  16. 16. 4. Gems
  17. 17. Any gem that works with Ruby 1.9 should work with MacRuby
  18. 18. 5. Behaviour-Driven Development
  19. 19. MacBaconA small RSpec clone, with NSRunLooppowers.https://github.com/alloy/MacBacon
  20. 20. 6. Mac App Store
  21. 21. http://briquetteapp.com/
  22. 22. http://shop.oreilly.com/product/ 0636920000723.do http://manning.com/lim/
  23. 23. RubyMotionBuilt on top of MacRubyUses a new LLVM-based static compiler thatgenerates optimized machine codeMemory model similar to Objective-C ARCBased on Rakehttp://www.rubymotion.com/
  24. 24. RubyMotionCommercial product. Educational licensesavailable at discounted price.Laurent Sansonetti left Apple to work on it.Released May 3rd, 2012Fast growing community!
  25. 25. $ motion create HelloMadridrbHelloMadridrb app .rb files app_delegate.rb Main delegate resources Images, Sounds, .xib files spec Tests main_spec.rb .gitignore Rakefile Configuration file
  26. 26. 1. Interactive Console
  27. 27. Holding and clicking in aUI element assigns thatelement to the self variable inthe console
  28. 28. 2. CocoaPods
  29. 29. CocoaPods is like RubyGems but for Ojective-Cprojects. $ sudo gem install cocoapods $ pod setup $ sudo gem install motion-cocoapodsChoose a pod:https://github.com/CocoaPods/SpecsEdit Rakefile: require motion-cocoapods Motion::Project::App.setup do |app| # ... app.pods do dependency JSONKit end end
  30. 30. 3. TestFlight
  31. 31. TestFlight helps you distribute development buildsof your app to your betatesters.$ sudo gem install motion-testflightDownload TestFlight’s SDK and put it in the “vendor” directory inside yourapp. http://testflightapp.com/sdk/downloadEdit Rakefile:require motion-testflightMotion::Project::App.setup do |app| # ... app.testflight.sdk = vendor/TestFlight app.testflight.api_token = <API token> app.testflight.team_token = <team token>endRun:$ rake testflight notes=First release!
  32. 32. 4. App Store
  33. 33. Mustachiohttp://itunes.apple.com/us/app/ mustachio/id525324802 https://github.com/HipByte/ Mustachio
  34. 34. Demo time
  35. 35. Questions?
  36. 36. No, it doesn’t run Rails.

×