consultant:tata consultancy services ltd
1 man army. amit tried it out, liekd it, built 3 apps, 1 will be on app store soon
then 2 man army!
what exactly is rubymotion?
a commercial fork of macruby, a ruby implementation of mac osx.
it compiles into optimized machine code. assembly language by llvm.
automatic object memory allocation and reclaim. first moment of happiness!
compiles the intervaces built in IB of XCode – second moment of happiness
ruby-runtime tightly integrated with Obj-C runtime. Same ancestor as Obj-C.
you can share objects between your ruby code and your objc code with no performance cost. compiles into executables
rubymotion and objective c has a shared runtime.
has a shared ancestory, the foundation framework (NSObject – Kernel)
can call all sdk apis from your ruby applications.
Can I code using RubyMotion without the pain of learning the Cocoa Framework? (asked us to guess) No.
You want to control the code you’re writing. You don’t believe in magic. I want to build my interface myself with code.
Second question: when there are frameworks like PhoneGap, why should I care about RubyMotion?
how do i download rubymotion? $200
“i never regretted it”
after you download and install, you see the motion command.
$ motion –help
shows you motion create, activate, update, support. very cool because from your console, you have access to the suport ticket system of rubymotion. opens the default browser on your machine with certain fields filled out already: lic key, info about machine, you fill in the bug report or feature request.
if you want to stick to a certain version, you’ll have to use this
sudo motion update –force-version=1.2
app delegate class
let’s look at the motion rake command
in rubymotion, your bread and butter is rake. develop, test, and deploy: you’ll be using rake.
rake default: build the project, run the simulator.
rake spec: run the test/spec suite, comes with a rspec-like frameowrk called macbacon (?), all the flavors of rspec
rake build: builds the application
rake archive: creates an ipa file you can distribute or push to app store
build, test deploy. (those are the
rake config: every ios application has a bunch of configuration options.
frameworks (bunch of frameworks in cocoa. defaults: UIKit, Foundation, coreGraphics
device_family: iphone, ipad, or both
when you fire rake, starts compiles your ruby source code.
pro-tip: other configuration options
let’s look at the soul of a rubymotion app.
console REPL: read evaluate print loop. demo!
opens the simulator!! also builds project.
is the prompt.
(main)> @controller = App.delegate.instance_variable_get(:@ui_view_controller)
(main)> @controller.view.backgroundColor = UIColor.whiteColor
wow, it makes the color white!
(main)> @segment = UISegmentedControl.bar([“Hello”, “Patient Attendees”])
makes it, but hasn’t addd to the view, so here
(main)> @controller.view <
it appeared! two blue buttons on the top left.
now move it 100px down and 200 px to the right. will use another RubyMotion gem, called sugarcube
(moves it down 200)
(moves it right 100)
this is one way of playing with it. there is another way. hold the command key, and move the mouse. hovering over UIView, then the prompt changes. then you click it, main has changed to the object that you have highlighted. clicked on
quit (to get back to main)
shows you hierarchy
you feel in-control. another moment of happiness (our fourth!)
an excellent in-browser demo of repl: pieceable.com/rubymotion-console
like rails, rubymotion comes bundled with an rspec-like framework called: MacBacon
a test that’s the starting point of your application. saying that more tests can be added to your application.
we can look at the test: has one window.
launches simulator again, because it runs the test case in that environment.
MacBacon has almost all of the syntactic sugar that we are accustomed to in RSpec: assertions, matchers, before/after blocks.
view testing: loading the nib/xib/storyboard file.
Since we could not push to testflight, we set up continuous integration.
dev –> github –> webhook to jenkins server on a mac mini (important aspect to see here is the push from jenkins server to an app store we have ). over the air technology from apple, plist. browse to “app store” and see install button, then use a device to do that and test it.
can do these things:
rubygems – normal rubygems won’t work because rubymotion is statically compiled. rubymotion gems have to extend the configuration file. the authors of rubymotion gems have make sure compiler gets them.
lots of contributions from the commuity. big list. bubblewrap, teacup (stylesheet, moves away from building interface from code). sugarcube, formotion, some that he created and contributed back.
statically compiled :static
basic types in C have ruby counterparts, but for complex types in C, uses bridge
RM is only ~4 months old, has a long way to go.
some things that it lacks:
– debugger (REPL kind of makes it easy)
– some dynamic code doesn’t work (“but hey, who cares?” lol)
some apps in the app store made by rubymotion:
everclip, cabify, survey (his app!)
15% discount off rubymotion if you email email@example.com !