[MacRuby-devel] How to create loadable MacRuby bundle
antonin at hildebrand.cz
Mon Oct 13 23:08:38 PDT 2008
I'm porting my app from RubyCocoa to MacRuby. I wanted to implement
simple plugin system for this app..
Plugins contain not only ruby scripts, but also nib files (and maybe
other resource stuff).
I'm quite new to Mac development, so I may be totally wrong. My
approach was to create every plugin as a RubyCocoa loadable bundle.
In RubyCocoa during application startup I load all plugins using
NSBundle.bundleWithPath(path).load and it correctly does two things:
1. initializes nib machinery
2. calls my ruby script, in which I hook into main application (it
gives me the same ruby environment as has main application)
In ideal case I don't want limit plugin developers to use MacRuby,
RubyCocoa or any other particular technology.
I want them just to create loadable bundle and use my application
hooks in their init call (hooks should be accessible from their
I can imagine to write ruby C-extension inside my main application to
bridge ruby methods into C and present hooks to plugins as plain C API
(which everybody should understand).
If this is too complicated, I can live with just MacRuby bundle support.
On Tue, Oct 14, 2008 at 7:42 AM, Laurent Sansonetti
<lsansonetti at apple.com> wrote:
> Hi Antonin,
> On Oct 13, 2008, at 6:59 PM, Antonin Hildebrand wrote:
>> Is it possible to create loadable MacRuby bundle to be loaded into
>> another MacRuby application?
>> I'm looking for replacement for RBBundleInit as described for
>> RubyCocoa here:
>> I'm loading bundles into my MacRuby app via:
> trunk has a preliminary Objective-C API that allows pure Objective-C
> apps to initialize and use MacRuby (look at the MacRuby class defined
> in the objc.h file in trunk), and RBBundleInit could therefore be
> implemented based on that.
> Could you give more details about what you are trying to do exactly?
> Loading a MacRuby bundle in a MacRuby app looks weird, you could just
> require the Ruby scripts.
> If you want to load a .bundle that contains native code in a MacRuby
> app, you can use the NSBundle API. You could also generate a dynamic
> library and "require" it (assuming you have an Init_xxx exported
> If you want to load a .bundle that contains MacRuby code in a non-
> MacRuby application, you will need the new Objective-C API (or use the
> standard C API) to prepare the bundle. I could work on a sample code
> that illustrates this if needed. The bundle could theoretically be
> loaded in MacRuby apps as well, thought it would be a little bit
> overkill since you could just directly "require" the Ruby scripts.
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
More information about the MacRuby-devel