Share
Embed
RubyMotion: Rubyizing iOS development
Amit Kumar
September 15, 2012
Transcript
127 slides
-
About me • Ruby’ist • Consultant: Tata Consultancy Services Ltd
• Github: toamitkumar • Twitter: toamit • toamitkumar.github.com Sunday, September 16, 12 -
revolutionary toolchain for native iOS application development using Ruby language
RubyMotion Sunday, September 16, 12 -
revolutionary toolchain for native iOS application development using Ruby language
neighbor's envy coder’s delight; happiness; RubyMotion Sunday, September 16, 12 -
Fork of MacRuby A What ?? Compiles into optimized machine
code Sunday, September 16, 12 -
Fork of MacRuby Automatic object memory allocation and reclaim A
What ?? Compiles into optimized machine code Sunday, September 16, 12 -
Fork of MacRuby Automatic object memory allocation and reclaim A
What ?? Compiles into optimized machine code Sunday, September 16, 12 -
Fork of MacRuby Automatic object memory allocation and reclaim A
What ?? Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12 -
Fork of MacRuby Automatic object memory allocation and reclaim A
What ?? Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12 -
Ruby-runtime tightly integrated with Obj-C runtime Fork of MacRuby Automatic
object memory allocation and reclaim A What ?? Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12 -
Ruby-runtime tightly integrated with Obj-C runtime Fork of MacRuby Automatic
object memory allocation and reclaim A What ?? Same ancestor as Obj-C Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12 -
A What ?? Ruby-runtime tightly integrated with Obj-C runtime Fork
of MacRuby Automatic object memory allocation and reclaim Same ancestor as Obj-C Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12 -
A What ?? Object can be shared with no performance
cost Ruby-runtime tightly integrated with Obj-C runtime Fork of MacRuby Automatic object memory allocation and reclaim Same ancestor as Obj-C Compiles into optimized machine code Compiles the interfaces built in IB of XCode Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: - Its a bridge that makes native api calls Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: - Its a bridge that makes native api calls - Runs in single thread of UIWebView which is painfully slow Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: - Its a bridge that makes native api calls - Runs in single thread of UIWebView which is painfully slow - Limited support of direct access to native APIs Sunday, September 16, 12 -
Myths Can I code using RubyMotion without the pain to
learn Cocoa Framework ? PhoneGap like tools are much easier to learn what advantage do I get with RubyMotion ? Pros: - Very easy to get started; as we all know HTML/JS/CSS Cons: - Its a bridge that makes native api calls - Runs in single thread of UIWebView which is painfully slow - Limited support of direct access to native APIs - Debugging becomes extremely difficult when you make native api calls Sunday, September 16, 12 -
The ‘motion’ command Protip: Forcing update to a particular version:
Sunday, September 16, 12 -
The ‘motion’ command Protip: Forcing update to a particular version:
Sunday, September 16, 12 -
The ‘motion’ command Protip: Forcing update to a particular version:
sudo motion update --force-version=1.2 Sunday, September 16, 12 -
Configuration ‘options’ Pro-tip: Other configuration options app.file_dependencies ‘app/controllers/curves_controller.rb’ => ‘app/controllers/main_controller.rb’
app.vendor_project Sunday, September 16, 12 -
The Soul Console REPL - Read Evaluate Print Loop Sunday,
September 16, 12 -
The Soul Console REPL - Read Evaluate Print Loop You
feel in-control Sunday, September 16, 12 -
The Soul Console REPL - Read Evaluate Print Loop You
feel in-control Sunday, September 16, 12 -
The Soul Console REPL - Read Evaluate Print Loop You
feel in-control An excellent in-browser demo of REPL: https://www.pieceable.com/rubymotion-console Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers - before/after blocks Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers - before/after blocks View testing: Sunday, September 16, 12 -
Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’
like framework ‘MacBacon’ <motion_root>/spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers - before/after blocks View testing: - Loading the nib/xib/storyboard file Sunday, September 16, 12 -
Continuos Integration WebHook Jenkins setup on mac-mini App Store Push
Setup for local deployment and testing Sunday, September 16, 12 -
RubyGems Normal RubyGems won’t work Motion::Project::App.setup do |app| # Load
files from gem end Sunday, September 16, 12 -
RubyGems Normal RubyGems won’t work Use Bundler Motion::Project::App.setup do |app|
# Load files from gem end Sunday, September 16, 12 -
RubyGems Normal RubyGems won’t work Use Bundler source :rubygems gem
'rake' gem 'bubble-wrap' gem 'motion-cocoapods' gem 'motion-redgreen' Gemfile require ‘bundler’ Bundler.require Rakefile Motion::Project::App.setup do |app| # Load files from gem end Sunday, September 16, 12 -
RubyGems contd... Bubblewrap teacup sugarcube formotion Nitron motion-redgreen motion-logger MotionModel
NativeJSBridge SegmentTab Sunday, September 16, 12 -
Statically Compiled app.vendor_project( “vendor/project-name”, #should have both .h and .m
file :static ) Using Obj-C code Sunday, September 16, 12 -
Statically Compiled app.vendor_project( “vendor/project-name”, #should have both .h and .m
file :static ) Using Obj-C code Sunday, September 16, 12 -
Statically Compiled app.vendor_project( “vendor/project-name”, #should have both .h and .m
file :static ) Using Obj-C code XCode project: app.vendor_project( “vendor/project-name”, :xcode, :xcodeproj => “project-name.xcodeproj”, :target => “project-name”, :products => [“libproject-name.a”], :headers_dir => “project-name” ) Sunday, September 16, 12 -
Using native C code Basic Types in C (bool, char,
int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) Sunday, September 16, 12 -
Using native C code Basic Types in C (bool, char,
int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) C Complex Data Structures Sunday, September 16, 12 -
Using native C code Basic Types in C (bool, char,
int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) C Complex Data Structures No corresponding Ruby Data Types Sunday, September 16, 12 -
Using native C code Basic Types in C (bool, char,
int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) C Complex Data Structures No corresponding Ruby Data Types Sunday, September 16, 12 -
Using native C code Basic Types in C (bool, char,
int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) BridgeSupport C Complex Data Structures No corresponding Ruby Data Types Sunday, September 16, 12 -
Using native C code Basic Types in C (bool, char,
int, long, float, double) Ruby data types (true/false, Fixnum, Bignum, Float) RubyMotion BridgeSupport C Complex Data Structures No corresponding Ruby Data Types Sunday, September 16, 12 -
CocoaPods is a dependency manager for Obj-C projects sudo gem
install cocoapods Sunday, September 16, 12 -
CocoaPods is a dependency manager for Obj-C projects sudo gem
install cocoapods pod setup # this may not be required for everyone, it never worked for me Sunday, September 16, 12 -
CocoaPods is a dependency manager for Obj-C projects sudo gem
install cocoapods pod setup # this may not be required for everyone, it never worked for me https://github.com/CocoaPods/Specs - lists all the pods Sunday, September 16, 12 -
CocoaPods is a dependency manager for Obj-C projects sudo gem
install cocoapods pod setup # this may not be required for everyone, it never worked for me https://github.com/CocoaPods/Specs - lists all the pods It has been integrated with RubyMotion which comes as a gem Sunday, September 16, 12 -
CocoaPods is a dependency manager for Obj-C projects sudo gem
install cocoapods pod setup # this may not be required for everyone, it never worked for me https://github.com/CocoaPods/Specs - lists all the pods It has been integrated with RubyMotion which comes as a gem sudo gem install motion-cocoapods Sunday, September 16, 12 -
CocoaPods is a dependency manager for Obj-C projects sudo gem
install cocoapods pod setup # this may not be required for everyone, it never worked for me https://github.com/CocoaPods/Specs - lists all the pods It has been integrated with RubyMotion which comes as a gem sudo gem install motion-cocoapods Include it in your Rakefile: require ‘moion-‐cocoapods’ Motion::Project::App.setup do |app| # ... app.pods do dependency 'JSONKit' dependency 'iActiveRecord' end end Sunday, September 16, 12 -
Long way to go ! RM is only ~4 months
old Sunday, September 16, 12 -
Long way to go ! RM is only ~4 months
old Something it lacks: - Debugger (but REPL kind of makes it easy) - Some dynamic code doesn’t work (but hey !!!) Sunday, September 16, 12