Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I just finished building an Objective-C library that uses the Core Location framework. Now I want to take that library and use it in a C program. I'm just building the C program so that I can then use the library to extend Ruby.

Right now, I just want to learn enough C to accomplish this particular task.
 

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
You need an Objective-C runtime for the code to work. If you want Ruby to call Objective-C:
http://en.m.wikipedia.org/wiki/RubyCocoa#How_to_call_Objective-C_methods_from_Ruby

If you want C to get you there, just keep in mind you're really writing an Objective-C program, it just happens you stuck with straight C for some methods. Eventually, either with []s or objc_msgsend you're going to pass an Objective-C.

-Lee

Thanks.

Edit: The documentation makes it seem like RubyCocoa is for developing apps, not Ruby extensions.
 

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I'm thinking that writing a scriptable command-line tool would be as good of a solution as, if not better than, using RubyCocoa.

I think that I could build a tool that uses all of the native frameworks I want to use and has an AppleScript API that I can later invoke in Ruby.

Here's the thing. I want to be able to use the library in a command-line program. The library does not need a GUI to function.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Unless your library is plain C you will need the Objective-C runtime, GUI or not.

You can certainly write an Objective-C command-line app, then interact with it however you'd like. I'm not totally clear where AppleScript gets involved here. It seems to up the complexity. I assume your Ruby code could just invoke the command line tool directly.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.