Question

I want to call certain Ruby libraries (natural language processing) from Objective C ( it's a Mac OSX app). I would like however to keep the most of the programming in Objective C, using Ruby only to use that particular library that is in Ruby.

I looked at MacRuby and it seems, that I would be expected to use Ruby syntax across all the application, while I would rather use ObjC for the most part and just interface to one-two ruby classes.

I realize that I can just call ruby script from command line, but some kind of integration seems much more useful that that.

So the question is - can I achieve the described above flow with MacRuby or should I look into something else?

Was it helpful?

Solution

You can do this with MacRuby, but I don't think it will offer much benefit over the other options unless you need to interact very heavily between the two environments. MacRuby is more for interacting with the Objective-C world from Ruby than vice-versa, but it does allow you to freely mix the two languages in your project. To be honest, the simplest answer is just using the system Ruby. If this is unsuitable for some reason, you can use the Ruby C API to talk to the Ruby code. There's an example of this in Programming Ruby.

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