Nick
2004-Dec-16 20:52 UTC
[Fwd: Re: Ruby Cocoa (OS X) questions: deployment & interface builder]
This is a re-post (slightly edited) from the ruby-talk list. I think I''m going to add a wiki page on the topic. -------- Original Message -------- Subject: Re: Ruby Cocoa (OS X) questions: deployment & interface builder Date: Fri, 17 Dec 2004 07:48:26 +0900 From: Nick <devel@nicreations.com> Reply-To: ruby-talk@ruby-lang.org To: ruby-talk@ruby-lang.org (ruby-talk ML) References: <838ec8ff0412160946608bc574@mail.gmail.com>> I''m interested in Mac/Cocoa development. > > Are there tools available for .app packaging of Ruby/Cocoa apps? > Can this be done w/o reliance on the downlevel Ruby 1.6 included in > Panther?Actually, I''ve wrapped a number of ruby apps. If done right, ruby apps can look just like Mac OS X applications. The trick is that you need some PPC binary in the Contents/MacOS directory. I wrote a wrapper that links to the ruby static library, figures out where the Resources directory of the bundle is, and then executes "start.rb" in the resources directory. You can download it at: http://www.nicreations.com/boot.cpp To build it, use g++ -c -I<ruby include dir> -x objective-c++ -framework Cocoa boot.cpp g++ -o boot -L<ruby lib dir> -lruby-static -framework Cocoa boot.o An app is just a set of directories: Root.app + Contents Info.plist + MacOS boot (output binary) + Resources Ruby scripts and extensions The "executable" script needs to be named "start.rb". Any extensions need to be put into the Resources directory. For example, I put the wxruby.bundle in the Resources directory, and it allows me to create full GUI apps on the Mac. However, wxruby is a 4 mb library, and makes for a fat executable. (wxruby-swig will be build-able as a shared framework, allowing all wxruby apps to share a single framework). Finally, you need to create a Info.plist file in the Contents directory. It is a simple XML file OS X uses to get properties about your application. Here is a sample: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> <plist version="0.9"> <dict> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleIdentifier</key> <string>org.ruby.your.app.name.here</string> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>boot</string> <key>CFBundleName</key> <string>Your App Name</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>1.0</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleGetInfoString</key> <string>Your App Name (c) 2004 Your Name</string> <key>CFBundleLongVersionString</key> <string>Your App Name (c) 2004 Your Name</string> <key>NSHumanReadableCopyright</key> <string>Copyright 2004 Your Name</string> <key>LSRequiresCarbon</key> <true/> <key>CSResourcesFileMapped</key> <true/> </dict> </plist> You should change CFBundleIdentifier, CFBundleName, CFBundleGetInfoString, CFBundleLongVersionString, NSHumanReadableCopyright for your own application. If you take this approach, your ruby app will look and feel exactly like any other Mac application - and no one needs to know that your development time was one tenth everybody elses for using a better language. :-) Nick Michael DeHaan wrote:> Folks, > > I''m interested in Mac/Cocoa development. > > Are there tools available for .app packaging of Ruby/Cocoa apps? > Can this be done w/o reliance on the downlevel Ruby 1.6 included in > Panther? > > Anyhow, any pointers would be greatly appreciated. > > I guess, bottom line, is that i''d like to write applications that > other people can use -- so I''m a bit concerned about deployment > considerations. > > On a somewhat related note, is there a way of using interface files > w/o reliance on XCode and interface builder? I can''t see any > documentation to the effect that it is possible, but it must be > possible somehow... Coding in vim is preferable to me than using > XCode, it''s yet another interface to deal with and I like my > terminals! :) > > (Yes, I''ve asked about Ruby/Tk and Tcl/Tk Aqua before -- Tcl/Tk Aqua > does look awesome ... but that''s even a greater deployment problem, > IMHO... I was having substantial trouble setting it up even on my box > to work with Ruby per the Ruby Garden article) > > Thanks, > > --Michael DeHaan > > > >