Getting RubyMotion working on a fresh install of Mac OS X Lion
On Wednesday, I wanted to start hacking with RubyMotion. Because I was about to leave for a trip to HK, I didn't try it on my Mountain Lion (10.8) running iMac and instead resurrected an old Snow Leopard (10.6) running Macbook.
A quick read through RubyMotion's getting started guide and Apple's Developer portal made me realize that I needed XCode 4.5 in order to easily install the command line tools (autoconf, make, git, ...) and in order to use iOS SDK 6.
XCode 4.5 requires at least Mac OS X Lion (10.7), so had to upgrade the laptop (the Mac OS X Lion upgrade is not available anymore on the Mac App Store since Moutain Lion release and my Macbook is not supported by Mountain Lion, but I had thankfully kept on the iMac, a Mac OS X Lion installer I could re-use).
Once I got Lion, Xcode 4.5 and RubyMotion installed, I went through the Hello World example and encountered a few problems along the way.
First problem:
undefined method `count' for ["./app/app_delegate.rb"]:Array
This happen when running rake and after googling it turns it was because Ruby Motion requires at least ruby 1.8.7 and Lion comes with 1.8.6. I therefore decide to install and use RVM to install newer rubies which led to the second problem.
Second problem:
Readline related compilation error when installing any version of ruby using RVM.
After following several leads that didn't work for my setup, I finally found two blogs mentioning an approach that actually works:
-
http://www.iamseree.com/application-development/readline-6-2-make-error-in-mac-os-x-lion
-
http://rtmatheson.com/2011/09/installing-ruby-1-9-2-on-mac-os-x-10-7-lion/
This allowed me to install ruby 1.9.* and I subsequently got further with the Hello World problem, straight into problem no. 3.
Third Problem:
After compiling the Hello app, rake hangs while launching the iOS simulator. The simulator is visible but is frozen.
It turns out it was because I use tmux. If I re-run rake in new terminal, not in tmux, it works fine.
To get rake working with tmux, I had to install reattach-to-user-namespace using Homebrew and in my tmux session, instead of calling rake directly, I use:
reattach-to-user-namespace -l rake
It fixes the issue.
Fourth Problem:
CODESIGN_ALLOCATE error about ambiguous matching certificates is thrown by ruby motion when running rake device.
a post in the RubyMotion google group led to that Apple Tech. note that immediately helped: I had an older expired iOS developer certificate in my Mac OS X keychain. Removing it fixed the problem.
After all of that, RubyMotion now works for me.