RubyMotionはじめました

購入

公式サイト

のBuyから購入.
12,368円ぐらい($199.99からのディスカウントで$149.99)

クレカかPayPalで購入できます.
JCBは使えなかった.JCBはクソ.

購入したらInstallerのDL先とlicense keyがメールで届きます.

InstallerをDLして,起動するとlicense keyを入れるとインストールされます.




Getting

GettingStarted

を参考にHelloWorldをする.

まずはコマンドの確認.

$which motion
/usr/bin/motion


iOS SDKが入っている必要がありますが,僕の環境には既にXCodeが入っているので飛ばします.

RubyMotionのアップデートが無いか確認.

$motion -v
1.2
$sudo motion update
Password:
Connecting to the server….
Software is up to date
$ motion -v
1.2


最新でした.

Hello Worldします.

$motion create Hello
Create Hello
Create Hello/.gitignore
Create Hello/Rakefile
Create Hello/app
Create Hello/app/app_delegate.rb
Create Hello/resources
Create Hello/spec
Create Hello/spec/main_spec.rb
$cd Hello
$rake
===============================================================================
It appears that you have a version of Xcode installed in /Applications that has
not been set as the default version. It is possible that RubyMotion may be
using old versions of certain tools which could eventually cause issues.

To fix this problem, you can type the following command in the terminal:
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
===============================================================================
Build ./build/iPhoneSimulator-5.0-Development
Compile ./app/app_delegate.rb
Create ./build/iPhoneSimulator-5.0-Development/Hello.app
Link ./build/iPhoneSimulator-5.0-Development/Hello.app/Hello
Create ./build/iPhoneSimulator-5.0-Development/Hello.app/Info.plist
Create ./build/iPhoneSimulator-5.0-Development/Hello.app/PkgInfo
Create ./build/iPhoneSimulator-5.0-Development/Hello.dSYM
Simulate ./build/iPhoneSimulator-5.0-Development/Hello.app
2012-05-09 03:33:40.258 Hello[33099:f803] Applications are expected to have a root view controller at the end of application launch
(main)>>


で,シミュレータが起動しますが,何も書いていないので空です.

./app/app_delegate.rb

を編集します.

class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
alert = UIAlertView.alloc.initWithTitle(
"Title",
message:"message",
delegate:nil,
cancelButtonTitle:nil,
otherButtonTitles:"OK")
alert.message = "Hello World"
alert.show
true
end
end


ビルドし直します.

$rake


シミュレータが起動して,Alertが表示されます.

0 comments: