I am trying to use an external Obj-C class in my MacRuby project, but I can't figure out how to import it. Specifically, I want to use ObjectiveResource inside a MacRuby 0.5 project (since ActiveResource doesn't work - yet).

I have gotten as far as the 'framework' command in MacRuby, but it only seems to apply to actual frameworks.

Questions: where should I install the objective-resource directory? how do I pull these classes inside my ruby code?

(Edit) That said, perhaps the easiest way is to add a header file for your ruby file, containing your methods equivalents.

Suppose that you have this ruby class:

class Foo
def bar(moo)
"a string like #{moo}"
end
end

so the equivalent header file will be something like that:

@interface Foo : NSObject
- (NSString *)bar:(NSString *)moo
@end

Now, just #import the header and use your ruby classes as standard Obj-C ones from within your Obj-C code:

NSString *aString;
Foo *myFoo;
aString = [myFoo bar:@"me"];

It may seem weird, but it works. Essentially, the idea is to shut the compiler's mouth and let it compile your code without complaining about missing methods. Then, at runtime, it will just work (I suppose thanks to the dynamic nature of Obj-C itself). By the way, to mimic the ruby typeless behavior, id is your friend in writing methods signatures in the header file.

Yes, I have tried that, but I doesn't work at all for me. I did get a little closer by creating a bundle manually according to this (mail-archive.com/macruby-devel@lists.macosforge.org/…) example, but it is a very painful process and I haven't quite gotten it to work. I suppose the ObjectiveResource code (intended for iPhone apps) isn't all that suitable for this?
–
beno1604Mar 17 '10 at 21:22

1

What errors do you get when you try the bundle? Can you edit your post to include the error messages?
–
salMar 18 '10 at 19:19