Back

rubymotion 极速入门 (rubymotion guide)

发布时间: 2014-10-01 15:14:00

想在 ios开发中用ruby  ?  很简单。用rubymotion.

refer to: http://www.rubymotion.com/developer-center/guides/getting-started

1. 安装 xcode, 安装 command line tools

2. 安装 rubymotion (下载zip 文件,输入 注册码,安装)

3. 开始 hello world:

$ motion create MotionHello  
$ cd MotionHello

可以看到 Rakefile等各种文件:

apple@mac:/sg552/workspace/MotionHello$ ls
Gemfile		Rakefile	build		spec
Gemfile.lock	app		resources

Gemfile:  ruby gem 的定义文件。 
Rakefile:  rake 的定义文件。 每个motion项目都是rake驱动的。
build: 生成目标代码的目录
spec: 测试文件夹
app: 主要目录。里面是主要的IOS代码
resources: 用到的图片,MP3啥的。

然后,输入: $ rake, 就会看到: 

     Build ./build/iPhoneSimulator-8.0-Development
   Compile ./app/app_delegate.rb
    Create ./build/iPhoneSimulator-8.0-Development/MotionHello.app
      Link ./build/iPhoneSimulator-8.0-Development/MotionHello.app/MotionHello
    Create ./build/iPhoneSimulator-8.0-Development/MotionHello.app/PkgInfo
    Create ./build/iPhoneSimulator-8.0-Development/MotionHello.app/Info.plist
      Copy ./resources/[email protected]
    Create ./build/iPhoneSimulator-8.0-Development/MotionHello.dSYM
  Simulate ./build/iPhoneSimulator-8.0-Development/MotionHello.app

接下来显示一个黑屏。。。。 因为我们没有写任何代码,所以看到的app 中啥内容都没有。

最后,我们修改 app/app_delegate.rb : 

  1 class AppDelegate
  2   def application(application, didFinishLaunchingWithOptions:launchOptions)
  3       alert= UIAlertView.new
  4       alert.message = "hi , siwei~"
  5       alert.show
  6       true
  7   end
  8 end

然后运行: $rake , 就会看到 内容在 模拟器中出现了~ :

I Os Simulator Screen Shot 2014年10月1日 下午11.43.25

Back