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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With