Sign up for free and start using Tildee with great new features About  About Sign up ! Login Get more of Tildee  Advanced
What would you like to see ?  What's New The Best tutorials

How to get started building an iPad app using ProMotion and RubyMotion

Profile
New user
Last modification by jamonholmgren
January 29, 2013, 9:18 pm → version: 2
Language: English
Rating:
Viewed: 1865 times

1

You need a few things first:

1. A relatively modern Mac (I'm using my 2012 Mac Mini I bought for home)
2. A licensed copy of RubyMotion (www.rubymotion.com, $199)
3. Latest version of Xcode installed

Let's get started!

2

tildee tutorial imageFirst, open Terminal and go to your code projects folder.

3

tildee tutorial imageRun `motion create ipad-demo` to create a new RubyMotion app.

4

Now open it in your favorite code editor. Mine is Sublime Text 2.

5

tildee tutorial imageCreate a Gemfile (so we can use Bundler) and add the following:

source :rubygems

gem "ProMotion", :git => "git://github.com/clearsightstudio/ProMotion.git", :branch => "refactor"

6

tildee tutorial imageFrom the Terminal, run `bundle` to install ProMotion.

7

tildee tutorial imageOpen the app_delegate.rb file and replace the contents entirely with this:

class AppDelegate < ProMotion::AppDelegateParent
def on_load(app, options)

end
end

8

tildee tutorial imageNow we need to tell the simulator that we want to target iPad. Go to your Rakefile and add this line:

app.device_family = [:ipad]

Also add this to the top in place of `require 'motion/project'`:

require "rubygems"
require 'motion/project'
require 'bundler'
Bundler.require

9

tildee tutorial imageNow run `rake` in Terminal to compile and run your new app.

10

tildee tutorial imageThe simulator will show a black screen. We want something a little more exciting.

11

tildee tutorial imageAdd a folder named "screens" in your /app folder and create a file named "home_screen.rb" with these contents:

class HomeScreen < ProMotion::Screen
title "Home Screen"

def on_load
set_tab_bar_item system_icon: UITabBarSystemItemContacts
end
end

12

tildee tutorial imageWe want the app to open this screen in a tab bar on startup, so open up your app_delegate and add this line to the middle of the on_load method:

open_tab_bar HomeScreen

13

tildee tutorial imageKill the app by pressing Ctrl+C in your terminal and re-run `rake`. This time you'll see the tab bar below.

14

tildee tutorial imageLet's add an about_screen.rb too.

class AboutScreen < ProMotion::Screen
title "About Us"

def on_load
set_tab_bar_item system_icon: UITabBarSystemItemFeatured
end
end

15

tildee tutorial imageGo back to your app_delegate.rb and add it as a second tab.

open_tab_bar HomeScreen, AboutScreen

16

tildee tutorial imageRe-run `rake` and admire the two tabs.

17

That's all I have time for today. Go to my web design website, http://www.clearsightstudio.com/, to learn more about ProMotion and see other tutorials!
Rating
What do you think about this tutorial ?
Ads

  

Comments