00:00:05.550
Hi, I'm Colin Thomas-Arnold. I've been using RubyMotion since the day it was announced, and my goal today is to give an overview of what to do after you have downloaded it. That's usually the first question people ask. My handle is Colin ta on most platforms, and I reply to it. I am a RubyMotion architect and also administer the GitHub organization for RubyMotion.
00:00:16.049
So what is RubyMotion? RubyMotion compiles Ruby into native iOS code. It does not run Matz's Ruby interpreter or any interpreter at all; you end up with a compiled executable that can be submitted to the App Store. This is significant because nobody knows the difference. It’s very cool! The stack you need is simple: just a terminal and an editor. You do not have to use Xcode—I don’t, and I won’t during this talk.
00:00:52.530
I have a couple of sites open: my personal site, Colin ta, and a project called SweetTea, which is a combination of a couple of plugins. I’m also the lead developer on Teacup, which I'll be showing. The RubyMotion organization includes BubbleWrap, SugarCube, Teacup, and an underdevelopment website. When you get started with RubyMotion, you'll find that BubbleWrap and SugarCube are two essential gems—they wrap Objective-C code for you.
00:01:44.160
Installing RubyMotion provides you with the 'motion' command, which allows you to create a new project easily. Your usual toolset will feel very familiar. I'll create a gem file right now. I use Sublime Text, but I used TextMate for so long that I still use the 'mate' command to open files—old habits die hard! You end up with a gem file like the ones you're used to, and you also have a Rake file that gets compiled when you run 'rake'. We will see RubyMotion in action once we update it.
00:02:05.729
Now, let's have a look at what we have here. With 'rvm', you'll notice that many of the same tools are in play. The new version of RubyMotion has just been released, which is exciting! So now, compiling the app, here’s what our app currently looks like. We have an app delegate, and if you've worked with iOS, you’ll be familiar with this structure. This is a low-level approach, where you create the window manually and activate it. It throws an error right now, but that’s because we haven’t implemented any functionality yet.
00:03:04.380
I am going to create a controller; it won't do much at first. I will hand it to a navigation controller, and now we are starting to see a mix of iOS code and Ruby code. If you'll recognize Objective-C code and how it looks, you'll understand this transition. Now let's see how I'll use Teacup. Teacup works like a stylesheet, so I will define one and create an empty stylesheet for now. I will manually set up my views, something Xcode typically does for you.
00:05:06.250
I create a button, style it, and you'll notice this resembles CSS, but it’s all running in Ruby. We set dimensions and other properties in a similar way. Now looking at the app delegate again, I’ll assign my first controller. I will assign a handler to it, using a block. For reference, the Objective-C equivalent would typically involve more typing, such as implementing 'navigationController.pushViewController'. In RubyMotion, we abbreviate this process considerably. The final steps will show that I did write an app.
00:05:46.199
If you're interested in RubyMotion, please come talk to me afterward. I'd love to meet fellow RubyMotion developers!