[MacRuby-devel] Mixing Objective-C and Ruby classes

Brian Chapados chapbr at gmail.com
Tue May 19 15:59:49 PDT 2009


Those symbols are defined in the Carbon framework. Try compiling with:

cc shortcut.m -o shortcut.bundle -g -framework Foundation -framework
Carbon -dynamiclib -fobjc-gc -arch i386 -arch x86_64

On Tue, May 19, 2009 at 1:32 PM, isaac kearse <isaackearse at gmail.com> wrote:
> Hi Guys,
> I am writing a hotcocoa app, and I want to register a global keyboard
> shortcut so that I can perform an action in my app from any application.
> AFAIK you need to go down to Carbon to do this as documented here:
> http://cocoasamurai.blogspot.com/2009/03/global-keyboard-shortcuts-with-carbon.html
> This is the code I have so far: http://gist.github.com/114372
> When I try and package this as a bundle using the technique that Laurent
> demonstrated earlier in this thread I get these errors:
> isaac:~/src/tasks isaac$ gcc shortcut.m -o shortcut.bundle -g -framework
> Foundation -dynamiclib -fobjc-gc -arch i386 -arch x86_64
> shortcut.m: In function ‘-[Shortcut addShortcut]’:
> shortcut.m:25: warning: passing argument 1 of ‘InstallEventHandler’ makes
> pointer from integer without a cast
> shortcut.m:28: warning: passing argument 4 of ‘RegisterEventHotKey’ makes
> pointer from integer without a cast
> Undefined symbols:
>   "_GetApplicationEventTarget", referenced from:
>       -[Shortcut addShortcut] in cckmYEc0.o
>       -[Shortcut addShortcut] in cckmYEc0.o
>   "_RegisterEventHotKey", referenced from:
>       -[Shortcut addShortcut] in cckmYEc0.o
>   "_InstallEventHandler", referenced from:
>       -[Shortcut addShortcut] in cckmYEc0.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> Undefined symbols:
>   "_GetApplicationEventTarget", referenced from:
>       -[Shortcut addShortcut] in ccIWfnrB.o
>       -[Shortcut addShortcut] in ccIWfnrB.o
>   "_RegisterEventHotKey", referenced from:
>       -[Shortcut addShortcut] in ccIWfnrB.o
>   "_InstallEventHandler", referenced from:
>       -[Shortcut addShortcut] in ccIWfnrB.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> lipo: can't open input file:
> /var/folders/sm/smWEZrv7GueXZu2JpgAAuU+++TI/-Tmp-//ccX5Acy0.out (No such
> file or directory)
> I really have no idea what I'm doing here, so any ideas would be appreciated
> :)
> Cheers,
> Isaac
> On Mon, Apr 20, 2009 at 11:49 PM, victor jalencas
> <macruby-devel at principia.info> wrote:
>>
>> Many thanks John and Laurent.
>>
>>  After reading your messages I came back to XCode and discovered I had
>> made a typo in the ObjC part of the code (which, curiously, compiled)
>> and that's why my ruby code didn't find my selector.
>>
>>  As for calling ruby code from the obj-c side, I agree it's a bit
>> convoluted (not to mention deprecated). I hope there's a better way to
>> do that in store for upcoming versions. If I understood well your
>> example, you first created the Obj-C subclass and later, dynamically,
>> set its parent to be the ruby class. Anyway, seeing that the norm in
>> Cocoa is delegation rather than extension, and if all ruby classes are
>> readily available in Obj-C, I think I'll manage with just calling ruby
>> code instead of extending it. Apparently I lacked only calling the
>> sharedRuntime method, will need to experiment a bit more when I get
>> back to my Mac.
>>
>>
>>
>> cheers,
>> Victor
>>
>> --
>> --
>> Victor Jalencas <victor at carotena.net>
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>


More information about the MacRuby-devel mailing list