Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Ruby/Python code in an iPhone OS app?

My app needs to use a library which is only available for Python and Ruby. From my understanding, Apple allows Ruby to run on iPhone as long as users can't execute arbitrary code (Rhomobile uses Ruby).

How can I bundle Ruby/Python with my app, call a function from my Obj-C code, and get the result (a string) back in C or Obj-C format?

like image 348
igul222 Avatar asked Apr 23 '10 21:04

igul222


1 Answers

You can't. The new SDK agreement prohibits using original languages other than C, C++, or Objective-C, and the SDK agreement has always prohibited dynamically interpreting code. There's some ambiguity about how these rules will be enforced, but to be safe, it's best to avoid other languages until the kinks get worked out.

EDIT: In addition, as far as I know, there's no current technical way to run Python on the iPhone, as per this question. I've heard of embedding Lua in iPhone apps, but not Python. You can do Python with a jailbroken iPhone, but not through the app store.

The Ruby situation is almost as bad, as per this question. The iPhone doesn't ship with a Ruby interpreter, and compilers are a long ways off from working. Rhomobile works by packaging an interpreter and framework with the executable, which I highly doubt will make it past the new SDK agreement. If you really want to use Ruby, Rhomobile would probably be the best bet (as implementing your own interpreter would probably be a lot of work, and equally as unlikely to be approved). It's a rather depressing landscape at the moment--the most we can hope for is that MacRuby will eventually work, and Apple will approve it. That's a long ways off, though.

EDIT 2: I also just found out about tinypy, which could potentially work for Python. I doubt it would run real libraries though.

like image 192
shosti Avatar answered Sep 30 '22 02:09

shosti