2011年3月30日水曜日

hotcocoaでGUIアプリ



Hotcocoaというフレームワーク(ライブラリ?)を見つける。
Rubyではなく、MacRubyに包括されているらしいです。
参考:http://www.textdrop.net/soft/macruby-03/

Cocoaプログラミングをやってくれるものらしく、簡単にGUIアプリが書けるらしい。
ということで、さっそく動かしてみようとするが、MacRubyが入っていない…。

手でインストールするんだけど、ソースコードしかない情報がたくさんあったけど、普通に公式サイトからzipをダウンロードして、パッケージからインストールしました。
参考:http://www.macruby.org/downloads.html

んでもって、macgemというgemではないモノがインストールされたので、これを利用してhotcocoaをインストール。 

$ sudo macgem install hotcocoa

ようやく実行出来る!って思って、以下のソースをコンパイル+実行してみる。

ソースコード:

$ cat hotcocoa_test.rb
require 'hotcocoa'
include HotCocoa

application do |app|

window :size => [100, 50] do |win|
b = button :title => 'Hello'
b.on_action { puts 'World!' }
win << b
end
end
コンパイル:
$ hotcocoa hotcocoa_test.rb
$ cd hotcocoa_test
$ ls
Rakefile config lib resources
$ macrake
(in /Users/***/Documents/prog/rb/hotcocoa_test)
ld: warning: in /Library/Frameworks//MacRuby.framework/MacRuby, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_macruby_main", referenced from:
_main in ccE6DYYW.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/93/93tYOnyhHwuzyA++XUKg5++++TI/-Tmp-//ccUq5GxN.out (No such file or directory)
/bin/sh: ./Hotcocoa Test.app/Contents/MacOS/HotcocoaTest: No such file or directory

あー、また何かエラー出てるよw
"i386"のメッセージ的に、x64環境だと何か設定が必要なのかも…。

0 件のコメント:

コメントを投稿