Rubymotion Logo

I was playing around with RubyMotion and the Objective-C iHasApp library. Given that it’s just three files that are needed (a .m, a .h, and a JSON data file) I’d figured I’d have it working in no time. I was wrong.

iHasApp: Undefined

My first attempt involved me copying the three files to a vendor/iHasApp directory inside my app. Then, in my Rakefile I added the line:

app.vendor_project 'vendor/iHasApp', :static

Well, that was easy! Let’s run the app. Whoops!

... undefined local variable or method `iHasApp' for <MyController:0x9607730> (NameError)

Everything looked fine in my app as I had a properly generated .bridgesupport file. Hmmm, what was it?

I figured that my problem could have been due to there not being an .a file (SPOILER ALERT: it wasn’t :)).

I then went on to try using the CocoaPod, using motion-cocoapods, but it yielded the same result.

Searching and Searching

So off to Google I went, searching and searching. I couldn’t figure out what was wrong. Pretty frustrating. In the end I wasn’t searching for the right thing. Thankfully I stumbled upon an answer by Laurent Sansonetti on the RubyMotion Google Group. DUH! “The problem is that the iSpeechSDK class name starts with a lower-case letter, which is not a valid constant name in Ruby.” This same thing applies to iHasApp, doesn’t it? The fix is simple, just use IHasApp.alloc.init instead of iHasApp.alloc.init. Super easy fix (and obvious), but finding the answer was quite a challenge.