[MacRuby-devel] Getting from (Ruby)Cocoa to MacRuby?
Laurent Sansonetti
lsansonetti at apple.com
Mon Oct 27 01:06:53 PDT 2008
On Oct 26, 2008, at 12:27 AM, Rich Morin wrote:
> On a related topic, I'm wondering about the possibility of porting
> conventional (ie, ObjC) Cocoa apps _incrementally_ to MacRuby. Is
> there a way, for example, to:
>
> - Turn an ObjC Cocoa app into a nominal MacRuby app, but leave
> all of the actual code on ObjC.
>
> - Pick a class and method, comment out the ObjC code, and add
> a MacRuby version that performs the same job.
>
> - See if things still work the same.
>
> - Rinse, repeat...
There is a way :-)
- You modify the project to link against MacRuby.framework
- You copy the main.m and rb_main.rb files from an existing MacRuby
application (you will override the existing main.m file here, but
rb_main.rb will be a new file)
- You add a build phase that copies all .rb files into the Resource
directory of the application bundle
- Then you can start porting the code. You can start by converting a
file into MacRuby (MyClass.[m|h] -> MyClass.rb), then remove the C/
Objective-C files from the project.
I did this process quite a few times when porting some Objective-C
sample code into RubyCocoa/MacRuby. I don't think I forgot to mention
a step.
Laurent
More information about the MacRuby-devel
mailing list