Skip to content

Moving an Xcode Project to MacRuby from Objective C

isaac edited this page Apr 12, 2012 · 1 revision

Moving an Xcode project from Objective-C to MacRuby can be useful as a way to create a MacRuby example. The Xcode distribution, in particular, contains dozens of example projects which could serve as starting points. One might also wish to convert a real-world application in order to benefit from MacRuby's flexibility, assorted Ruby libraries, etc.

However, performing such a conversion in a single step is risky, because multiple translation errors may conspire to complicate debugging. Fortunately, it is possible to move projects in an incremental manner.


  • Make a copy of an existing project.

  • Modify the copy to link against the !MacRuby framework.

    • Copy in main.m from an existing !MacRuby application (change).
    • Copy in rb_main.rb from an existing !MacRuby application (addition).
  • Add a build phase that copies *.rb into the Resource directory of the application bundle.
  • Try out the copied project, to make sure it still runs properly.

Coding Changes

  • Convert a file from Objective-C to MacRuby.
    • Create SomeClass.rb, corresponding to SomeClass.[mh].
    • In SomeClass.rb, define a replacement method (and class, if need be).
    • Comment out the Objective-C method.
    • Try out the new method, to make sure it still runs properly.
  • Once an Objective-C file contains only comments, it can be removed.
Something went wrong with that request. Please try again.