Slide 1

Slide 1 text

Ruby’izing iOS Development Amit Kumar Sunday, September 16, 12

Slide 2

Slide 2 text

About me • Ruby’ist • Consultant: Tata Consultancy Services Ltd • Github: toamitkumar • Twitter: toamit • toamitkumar.github.com Sunday, September 16, 12

Slide 3

Slide 3 text

Sunday, September 16, 12

Slide 4

Slide 4 text

Released in May, 2012 Sunday, September 16, 12

Slide 5

Slide 5 text

Released in May, 2012 Sunday, September 16, 12

Slide 6

Slide 6 text

RubyMotion Sunday, September 16, 12

Slide 7

Slide 7 text

revolutionary toolchain for native iOS application development using Ruby language RubyMotion Sunday, September 16, 12

Slide 8

Slide 8 text

revolutionary toolchain for native iOS application development using Ruby language neighbor's envy coder’s delight; happiness; RubyMotion Sunday, September 16, 12

Slide 9

Slide 9 text

A What ?? Sunday, September 16, 12

Slide 10

Slide 10 text

A What ?? Sunday, September 16, 12

Slide 11

Slide 11 text

Fork of MacRuby A What ?? Sunday, September 16, 12

Slide 12

Slide 12 text

Fork of MacRuby A What ?? Compiles into optimized machine code Sunday, September 16, 12

Slide 13

Slide 13 text

Fork of MacRuby Automatic object memory allocation and reclaim A What ?? Compiles into optimized machine code Sunday, September 16, 12

Slide 14

Slide 14 text

Fork of MacRuby Automatic object memory allocation and reclaim A What ?? Compiles into optimized machine code Sunday, September 16, 12

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

A What ?? Sunday, September 16, 12

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Motion Runtime Sunday, September 16, 12

Slide 23

Slide 23 text

Motion Runtime Sunday, September 16, 12

Slide 24

Slide 24 text

Motion Runtime Sunday, September 16, 12

Slide 25

Slide 25 text

Shared Runtime Motion Runtime Sunday, September 16, 12

Slide 26

Slide 26 text

Shared Runtime Motion Runtime Sunday, September 16, 12

Slide 27

Slide 27 text

Shared Runtime Motion Runtime Sunday, September 16, 12

Slide 28

Slide 28 text

Foundation Framework (NSObject - Kernel) Shared Runtime Motion Runtime Sunday, September 16, 12

Slide 29

Slide 29 text

Foundation Framework (NSObject - Kernel) Shared Runtime Motion Runtime Sunday, September 16, 12

Slide 30

Slide 30 text

Foundation Framework (NSObject - Kernel) Shared Runtime Motion Runtime Sunday, September 16, 12

Slide 31

Slide 31 text

Myths Sunday, September 16, 12

Slide 32

Slide 32 text

Myths Can I code using RubyMotion without the pain to learn Cocoa Framework ? Sunday, September 16, 12

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

Download & Install http://sites.fastspring.com/hipbyte/product/rubymotion Sunday, September 16, 12

Slide 42

Slide 42 text

The ‘motion’ command Sunday, September 16, 12

Slide 43

Slide 43 text

The ‘motion’ command Sunday, September 16, 12

Slide 44

Slide 44 text

The ‘motion’ command Sunday, September 16, 12

Slide 45

Slide 45 text

The ‘motion’ command Sunday, September 16, 12

Slide 46

Slide 46 text

The ‘motion’ command Sunday, September 16, 12

Slide 47

Slide 47 text

The ‘motion’ command Protip: Forcing update to a particular version: Sunday, September 16, 12

Slide 48

Slide 48 text

The ‘motion’ command Protip: Forcing update to a particular version: Sunday, September 16, 12

Slide 49

Slide 49 text

The ‘motion’ command Protip: Forcing update to a particular version: sudo motion update --force-version=1.2 Sunday, September 16, 12

Slide 50

Slide 50 text

The ‘motion’ command Sunday, September 16, 12

Slide 51

Slide 51 text

The famous ‘Rake’ Sunday, September 16, 12

Slide 52

Slide 52 text

The famous ‘Rake’ Sunday, September 16, 12

Slide 53

Slide 53 text

The famous ‘Rake’ Sunday, September 16, 12

Slide 54

Slide 54 text

The famous ‘Rake’ Sunday, September 16, 12

Slide 55

Slide 55 text

The famous ‘Rake’ Sunday, September 16, 12

Slide 56

Slide 56 text

The famous ‘Rake’ Sunday, September 16, 12

Slide 57

Slide 57 text

Configuration ‘options’ Sunday, September 16, 12

Slide 58

Slide 58 text

Configuration ‘options’ Sunday, September 16, 12

Slide 59

Slide 59 text

Configuration ‘options’ Sunday, September 16, 12

Slide 60

Slide 60 text

Configuration ‘options’ Sunday, September 16, 12

Slide 61

Slide 61 text

Configuration ‘options’ Sunday, September 16, 12

Slide 62

Slide 62 text

Configuration ‘options’ Sunday, September 16, 12

Slide 63

Slide 63 text

Configuration ‘options’ Pro-tip: Other configuration options Sunday, September 16, 12

Slide 64

Slide 64 text

Configuration ‘options’ Pro-tip: Other configuration options app.file_dependencies ‘app/controllers/curves_controller.rb’ => ‘app/controllers/main_controller.rb’ Sunday, September 16, 12

Slide 65

Slide 65 text

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

Slide 66

Slide 66 text

The Soul Console REPL - Read Evaluate Print Loop Sunday, September 16, 12

Slide 67

Slide 67 text

The Soul Console REPL - Read Evaluate Print Loop You feel in-control Sunday, September 16, 12

Slide 68

Slide 68 text

The Soul Console REPL - Read Evaluate Print Loop You feel in-control Sunday, September 16, 12

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

Build Process Sunday, September 16, 12

Slide 71

Slide 71 text

Build Process COMPILING Sunday, September 16, 12

Slide 72

Slide 72 text

Build Process COMPILING LINKING Sunday, September 16, 12

Slide 73

Slide 73 text

Build Process COMPILING LINKING PACKAGING Sunday, September 16, 12

Slide 74

Slide 74 text

Build Process COMPILING LINKING PACKAGING CODE SIGN Sunday, September 16, 12

Slide 75

Slide 75 text

Testing your code Sunday, September 16, 12

Slide 76

Slide 76 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ Sunday, September 16, 12

Slide 77

Slide 77 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ /spec/main_spec.rb Sunday, September 16, 12

Slide 78

Slide 78 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ /spec/main_spec.rb $ rake spec Sunday, September 16, 12

Slide 79

Slide 79 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ /spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: Sunday, September 16, 12

Slide 80

Slide 80 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ /spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions Sunday, September 16, 12

Slide 81

Slide 81 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ /spec/main_spec.rb $ rake spec ‘MacBacon’ has almost all ‘syntactic sugar’ that you are accustomed in RSpec: - Assertions - Matchers Sunday, September 16, 12

Slide 82

Slide 82 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ /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

Slide 83

Slide 83 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ /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

Slide 84

Slide 84 text

Testing your code Like Rails, RubyMotion comes bundled with ‘RSpec’ like framework ‘MacBacon’ /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

Slide 85

Slide 85 text

Continuos Integration WebHook Jenkins setup on mac-mini App Store Push Setup for local deployment and testing Sunday, September 16, 12

Slide 86

Slide 86 text

Using External Libraries Sunday, September 16, 12

Slide 87

Slide 87 text

Using External Libraries RubyGems Sunday, September 16, 12

Slide 88

Slide 88 text

Using External Libraries RubyGems Objective-C Project Sunday, September 16, 12

Slide 89

Slide 89 text

Using External Libraries RubyGems Objective-C Project Native-C Sunday, September 16, 12

Slide 90

Slide 90 text

Using External Libraries RubyGems Objective-C Project Native-C CocoaPods Sunday, September 16, 12

Slide 91

Slide 91 text

RubyGems Sunday, September 16, 12

Slide 92

Slide 92 text

RubyGems Normal RubyGems won’t work Sunday, September 16, 12

Slide 93

Slide 93 text

RubyGems Normal RubyGems won’t work Motion::Project::App.setup do |app| # Load files from gem end Sunday, September 16, 12

Slide 94

Slide 94 text

RubyGems Normal RubyGems won’t work Use Bundler Motion::Project::App.setup do |app| # Load files from gem end Sunday, September 16, 12

Slide 95

Slide 95 text

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

Slide 96

Slide 96 text

RubyGems contd... Sunday, September 16, 12

Slide 97

Slide 97 text

RubyGems contd... Bubblewrap teacup sugarcube formotion Nitron motion-redgreen motion-logger MotionModel NativeJSBridge SegmentTab Sunday, September 16, 12

Slide 98

Slide 98 text

Using Obj-C code Sunday, September 16, 12

Slide 99

Slide 99 text

Statically Compiled app.vendor_project( “vendor/project-name”, #should have both .h and .m file :static ) Using Obj-C code Sunday, September 16, 12

Slide 100

Slide 100 text

Statically Compiled app.vendor_project( “vendor/project-name”, #should have both .h and .m file :static ) Using Obj-C code Sunday, September 16, 12

Slide 101

Slide 101 text

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

Slide 102

Slide 102 text

Using native C code Sunday, September 16, 12

Slide 103

Slide 103 text

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

Slide 104

Slide 104 text

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

Slide 105

Slide 105 text

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

Slide 106

Slide 106 text

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

Slide 107

Slide 107 text

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

Slide 108

Slide 108 text

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

Slide 109

Slide 109 text

CocoaPods Sunday, September 16, 12

Slide 110

Slide 110 text

CocoaPods is a dependency manager for Obj-C projects Sunday, September 16, 12

Slide 111

Slide 111 text

CocoaPods is a dependency manager for Obj-C projects sudo gem install cocoapods Sunday, September 16, 12

Slide 112

Slide 112 text

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

Slide 113

Slide 113 text

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

Slide 114

Slide 114 text

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

Slide 115

Slide 115 text

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

Slide 116

Slide 116 text

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

Slide 117

Slide 117 text

Long way to go ! Sunday, September 16, 12

Slide 118

Slide 118 text

Long way to go ! RM is only ~4 months old Sunday, September 16, 12

Slide 119

Slide 119 text

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

Slide 120

Slide 120 text

RM applications on AppStore Sunday, September 16, 12

Slide 121

Slide 121 text

RM applications on AppStore Everclip Sunday, September 16, 12

Slide 122

Slide 122 text

RM applications on AppStore Everclip Cabify Sunday, September 16, 12

Slide 123

Slide 123 text

RM applications on AppStore Everclip Cabify Survey Sunday, September 16, 12

Slide 124

Slide 124 text

RM applications on AppStore Everclip Cabify http://signup.bigdayreminder.com/ Survey Sunday, September 16, 12

Slide 125

Slide 125 text

RM applications on AppStore Everclip Cabify http://signup.bigdayreminder.com/ http://jukely.com/ Survey Sunday, September 16, 12

Slide 126

Slide 126 text

THANK YOU Sunday, September 16, 12

Slide 127

Slide 127 text

One more thing ! 15% discount [email protected] Sunday, September 16, 12