6

For an App that is not going to be released on the AppStore I'm looking to embed an interpreter for easy scripting needs. Since I don't really like to get down with pure C, the interpreter should be an Objective C library.

While searching the web I've come across a couple of script interpreters for Objective C but whether those guys work on iPhone is not quite so clear. The one I found that apparently works well on iPhone is LuaCore which brings Lua scripting to iOS Apps.

Which Objective C scripting interpreters have you successfully embedded in iOS Apps?

Benjamin
  • 830
  • 1
  • 8
  • 16
  • 1
    As a follow-up to my own question, I've discovered the following link detailing a Lua / iPhone integration: http://www.grzmobile.com/blog/2009/12/1/integrating-lua-into-and-iphone-app-part-2.html – Benjamin Jul 24 '10 at 19:10
  • One more Lua pointer: http://www.mobileorchard.com/announcing-iphone-wax-native-uikit-iphone-apps-written-in-lua/ – Benjamin Jul 24 '10 at 19:27

3 Answers3

3

Some Javascript options:

  1. Using a headless WebKit instance
  2. Instantiate a custom build of JavaScriptCore
  3. CouchBase's attempt at getting SpiderMonkey running (more modern Javascript than V8)

Notice that the JS option will provide with a quite raw runtime environment, you'll probably need to write at least some of it yourself for it to be a convenient development environment.

Other languages:

  1. An attempt with Python.
  2. Clojure by way of a static build of JavaScriptCore (see point 2 above).
  3. The Nu language is also supposed to integrate well, and have a good Objective-C bridge.

I have only tried the first headless WebKit variant for Javascript, but plan to try as many of those listed as possible for a project during the coming months.

Update: I've used the Javascript method 1 (headless WebKit) a bit longer. I got it running quite effortlessly, and will stick with that for a while. But it has a huge drawback: you can't call back to native in an easy manner. I solved this by writing a PhoneGap inspired bridge that empties a command queue after the script has run.

I've also tried Python using the link I gave. I made it compile and execute some sample code, but it suffers from the same problem as using Js via headless WebKit, and since it consumes quite a bit of memory I skipped it for now. A callback command queue in the same spirit as the one I created with Js would be possible though. Another Python method would be to attempt to call into the Objective C runtime using ctypes. That approach is described in this answer.

Update 2: Here are several new(ish) links for running Scheme, with both interpreter and compilation options.

Community
  • 1
  • 1
Jacob Oscarson
  • 6,363
  • 1
  • 36
  • 46
3

I just stumbled upon a really decent description by Twitter user @mysterycoconut of how to get Lua support up and running.

Benjamin
  • 830
  • 1
  • 8
  • 16
1

Just discovered a post regarding scripting on iOS at answerspice.com.

Based on the post I evaluated Nu and had it up and running pretty quickly based on the Xcode project referenced in this discussion (thanks Tim!). I tested in the simulator and on an iPhone 4. So Nu is definitely among the scripting languages that can be embedded in an iOS App.

Benjamin
  • 830
  • 1
  • 8
  • 16