[MacRuby-devel] how to use self-created frameworks?

peter royal peter.royal at pobox.com
Sun Jan 4 22:05:28 PST 2009


howdy!

i'm doing some network i/o with macruby, and wanted to use the CF  
API's so they play nicely with a run loop on a worker thread.

to that end, i found http://code.google.com/p/cocoaasyncsocket/ which  
is a nice delegate-based cocoa wrapper on said API's

however, i'm having trouble making use of them in macruby.

my initial naive attempt was to just throw the .h and .m files into my  
project. with this, i got an 'AsyncSocket' class in ruby, but the  
selectors defined in the header weren't available (and as such, it was  
unusable)

i then tried creating a private framework, following the instructions  
at:

http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html#/ 
/apple_ref/doc/uid/20002258-106880-BAJJBIEF

this works, and i can now say: framework 'AsyncSocket' and it works  
fine. however, i run into the same problem, none of the selectors  
defined in the header are available.

i looked through the macruby source, and saw that when the 'framework'  
directive is encountered, in addition to adding the class, it looks  
for the BridgeSupport file. i had thought it was optional, but perhaps  
not?

so i tried generating a .bridgesupport file using:

gen_bridge_metadata -f AsyncSocket.framework -c -fobjc-gc-only (was  
dumping to stdout just for testing)

but then that process never finished. a control-c reveals:

C/usr/bin/gen_bridge_metadata:338:in ``': Interrupt
	from /usr/bin/gen_bridge_metadata:338:in `do_cpp'
	from /usr/bin/gen_bridge_metadata:45:in `path'
	from /usr/bin/gen_bridge_metadata:1692:in `scan_headers'
	from /usr/bin/gen_bridge_metadata:1690:in `map'
	from /usr/bin/gen_bridge_metadata:1690:in `scan_headers'
	from /usr/bin/gen_bridge_metadata:520:in `collect'
	from /usr/bin/gen_bridge_metadata:1957
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ 
ruby/1.8/optparse.rb:785:in `initialize'
	from /usr/bin/gen_bridge_metadata:1891:in `new'
	from /usr/bin/gen_bridge_metadata:1891


and looking at that line in the source, its waiting on a cpp  
compilation, but that's failing with:

cc1: error: AsyncSocket.framework/Headers/AsyncSocket.h: not a directory

... which is valid, since its a header file, not a directory.

the command its trying to run is:

/usr/bin/cpp-4.0 -D__APPLE_CPP__ -include /usr/include/ 
AvailabilityMacros.h -F""   "AsyncSocket.framework/Headers/ 
AsyncSocket.h" 2>/tmp/.cpp.err

... before i keep barking up the BridgeSupport tree.. is that the  
right path? or is there a simpler way to use an Objective-C class  
that's not from an Apple-supplied framework easily?

thanks!!

-pete


-- 
(peter.royal|osi)@pobox.com - http://fotap.org/~osi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2454 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20090104/94a3df28/attachment.bin>


More information about the MacRuby-devel mailing list