Question

Sometimes it's nice to open an interpreter, type out some code and see if it's working, rather than having to compile something large like an Xcode project just to quickly test something. Does an Objective-C Interpreter exist for the Mac, or am I out of luck?

UPDATE: There's a paid program in the App Store called CodeRunner, which lets you run Obj-C quickly (and several other languages). It's not an interpreter, but works pretty well for testing out ideas quickly: http://itunes.apple.com/us/app/coderunner/id433335799?mt=12

Was it helpful?

Solution

You can use F-Script, which is Smalltalk-based, but lets you interface with Cocoa. You can also embed it in your application, to let you inspect views and other things at runtime. It's quite useful. Edit: as pointed out in the comments, there are other great language bridges available, like PyObjC, RubyCocoa/MacRuby, Nu, etc. CINT is an example of a C interpreter, but not Obj-C.

As for an actual Objective-C interpreter, I don't think one really exists. But it's not too hard to set up a "Command Line Tool" project in Xcode, which gives you a really simple main.m file to try something in.

OTHER TIPS

For those arriving here late: Take a look at Tosti. A basic but pretty functional Objective-C interpreter.

It's a side-project I put on GitHub as there seems very little available at the moment. I'm using it to do some remote debugging. Support available.

RubyMotion allows you to use all of the Cocoa SDK's library (as far as I know there are 0 limitations due to the similarities between Ruby & Objective C), for example, at runtime. You can also of course use every Objective C library you can load into it as well. The only limitations are the same as all other IDE's, namely those set forth by Apple with regard to unapproved dynamic libraries.

Anyway, functions are syntactically very, very similar to Objective-C, in it surprised me that you can do this in such a way with ruby (normally you can't

#for example the in AppDelegate class
class AppDelegate
  def application(application, didFinishLaunchingWithOptions:launchOptions)
    #...
    true
  end
 end

when you run rake (equivalent to Build command in XCode), you of course do it from the console, and once your iPhone/iPad app is loaded to the simulator or your apple device, you then can control that device or simulator interactively via commands entered from the console.

Ruby Motion costs $200 bucks/year, so its not worth it just for the interactive shell feature though of course

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top