[MacRuby-devel] Loading bundled bundles; #require or #framework?

Nick Ludlam nick at recoil.org
Sun Jul 18 11:34:17 PDT 2010


Hi all,
sorry for the tongue-twister message subject, but I'm having a difficult time figuring out how #require works, within the context of loading custom Bundles at startup.

I've been following http://www.macruby.org/recipes/create-an-objective-c-bundle.html and have successfully created an obj-c wrapper around a c++ library in order to read id3 tags from mp3 files.

My obj-c class is called 'TagLibBundle' and I've implemented the following init method as specified:

  void Init_TagLibBundle(void) { }

So far, so good. I've added the bundle to a MacRuby project, and it's copied into the Frameworks/ folder in the app bundle during the build. I am able to load the bundle with the following statement:

  bundle_path = NSBundle.mainBundle.privateFrameworksPath
  NSBundle.bundleWithPath(bundle_path + "/TagLibBundle.bundle").loadAndReturnError(nil)

I can also load the bundle with:

  bundle_path = NSBundle.mainBundle.privateFrameworksPath
  framework(bundle_path + '/TagLibBundle.bundle')

So I have two questions:

Can I add the privateFrameWorksPath to the #framework search path, like you would with $:.unshift(path), and get rid of the absolute path?

And is the tutorial incorrect in using #require to load the bundle, where it should be #framework? Or have I got something wrong with my setup?

Thanks,
Nick



More information about the MacRuby-devel mailing list