[MacRuby-devel] Using compiled MacRuby objects from an Objective-C application
Justin Schumacher
justin at sweetspotdiabetes.com
Mon Dec 20 17:18:04 PST 2010
I'm working on an application that is primarily Objective-C but uses MacRuby
as a plugin language (the application also has a C# / IronRuby counterpart
on Windows, allowing for the plugins to be cross-platform). I've been
loading the ruby files at runtime using the Objective-C MacRuby API's
sharedRuntime and bundling MacRuby into the application bundle. However,
the ruby plugins have gotten complex enough that parsing them is taking
about 3 seconds at application startup on a modern MacBook Pro. I would
like reduce the load time by precompiling the ruby files and linking the
resulting object files to the application. So far I've done exactly that,
but I can't figure out how to access the ruby classes at runtime from the
Objective-C application.
I've tried two techniques:
// causes SIGABRT
id rubyClass = [[MacRuby sharedRuntime] evaluateString:@"MyRubyClass"];
- and -
// returns NULL
Class rubyClass = NSClassFromString(@"MyRubyClass");
I would love to see an example or description of how this can be done--- how
to link pre-compiled ruby files (dylib) to an Objective-C application and
then access the classes defined in those ruby files from the Objective-C
environment..
I've dug through the last 6 months of the archives, and I've found only one
other reference to this question, but it was left mostly unanswered:
http://lists.macosforge.org/pipermail/macruby-devel/2010-October/006206.html
-Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101220/27cf395f/attachment.html>
More information about the MacRuby-devel
mailing list