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

Laurent Sansonetti lsansonetti at apple.com
Wed Jul 21 21:10:50 PDT 2010


Hi Nick,

On Jul 21, 2010, at 4:14 PM, Nick Ludlam wrote:

> On 20 Jul 2010, at 19:49, Laurent Sansonetti wrote:
> 
>> On Jul 20, 2010, at 10:36 AM, Nick Ludlam wrote:
>> 
>>> On 19 Jul 2010, at 22:00, Laurent Sansonetti wrote:
>>> 
>>>> Hi Nick,
>>>> 
>>>> On Jul 18, 2010, at 11:34 AM, Nick Ludlam wrote:
>>>> 
>>>>> 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)
>>>> 
>>>> That should work. If you use NSBundle to load the bundle, then you don't need the Init function as discussed above. Otherwise, you can keep the Init function and you may be able to use #require here. 
>>> 
>>> I couldn't get #require to work, but that might be to do with the name of the bundle being 'TagLibBundle.bundle', rather than just 'TagLibBundle'. I need to investigate.
>> 
>> Strange, it should work if you pass a full path to the bundle file, file extension included.
> 
> 
> I tracked down why macirb wasn't able to load the bundle I was building from XCode. One was a misunderstanding, and one looks like a configuration problem.
> 
> Firstly, I was trying to require my bundle package directory, rather than the actual binary file contained in <BundleName>.bundle/Contents/MacOS/
> 
> Secondly, the binary file inside MacOS/ wasn't created with the .bundle suffix.  When I renamed the actual bundle binary, and I #require it directly, it works just fine.
> 
> Is there any way to have XCode build a bundle binary which isn't packaged in the usual 'bundle' way, with Contents/MacOS/ directories created? Also, setting 'Executable Extension' to 'bundle' in the project target settings doesn't seem to have any effect on the binary file contained inside Contents/MacOS/

I see the problem. I didn't know that by .bundle you meant an actual Mac OS bundle (a directory with stuff in it). Maybe there is a bug in the tutorial, #require can only deal with Mach-O bundles (created using the -bundle option of ld(1)), like C extensions in MacRuby.

Laurent


More information about the MacRuby-devel mailing list