开发者

Is there an Objective-C Interpreter for the Mac? [closed]

开发者 https://www.devze.com 2023-03-30 22:05 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site reso开发者_开发知识库urce are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

Improve this 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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号