# Objective-C Ruby Extension

**URL:** <https://www.ruby-forum.com/t/objective-c-ruby-extension/196321>\
**Category:** Ruby\
**Created:** [October 11, 2010, 5:42pm UTC](https://www.ruby-forum.com/t/objective-c-ruby-extension/196321 "2010-10-11T17:42:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zenlinuxnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b4bc9f/32.png) [@zenlinuxnh](https://www.ruby-forum.com/u/zenlinuxnh)\
**Post date:** [October 11, 2010, 5:42pm UTC](https://www.ruby-forum.com/t/objective-c-ruby-extension/196321/1 "2010-10-11T17:42:57Z")

</div>

Hi Everyone,

While toying around, I decided to start work on a trivial Objective-C  
Ruby Extension / eventual tutorial “because I can.” Which is the best  
reasoning for anything, ever. It’s a tad incomplete, but I’d love to  
get some feedback so far, if anyone has any:

[http://github.com/aitrus/objc\_ruby-ext](http://github.com/aitrus/objc_ruby-ext)

Note: This isn’t Mac specific, ala RubyCocoa / MacRuby / yadda.

Issues Getting it to Work:

- mkmf hardcodes the ‘.c’ extension as the only file extension that  
you can compile with the C compiler. You can work around this a  
variety of ways, but they’re all hackish.
- Data\_Get\_Struct does not work, as it seems to be checking to make  
sure you’re giving it a struct datatype. The only real work around  
for this was to pull out its DATA\_PTR line, bypassing its primitive  
type checking.  
– Rather than: Data\_Get\_Struct(self, Fraction, frac);  
– I write: frac = (Fraction\*)DATA\_PTR(self);

Everything seems to play just peachy with Ruby.

Scott
