Ruby Cocoa (OS X) questions: deployment & interface builder

M

Michael DeHaan

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
 
L

Lothar Scholz

Hello Michael,


MD> I guess, bottom line, is that i'd like to write applications that
MD> other people can use -- so I'm a bit concerned about deployment
MD> considerations.

MD> On a somewhat related note, is there a way of using interface files
MD> w/o reliance on XCode and interface builder? I can't see any
MD> documentation to the effect that it is possible, but it must be
MD> possible somehow... Coding in vim is preferable to me than using
MD> XCode, it's yet another interface to deal with and I like my
MD> terminals! :)

I agree here. I also tried to do a cocoa binding for Eiffel and
couldn't figure out how to avoid XCode / interface builder / nib
files.

I would really like to see a pure simple command line way to use
cocoa/aqua widgets without going the Object C way. And i doubt that
using nib files is very ruby like and also not very portable.
 
S

steven_todd_harris

Not to sound like an employee of the company or anything (I'm not It's
just that I relate to your questions and have asked the same ones so I
feel your pain), but I really suggest trying out the ambria stuff. I
also ran into this issue. Quite anoying. Ambria is in beta and is
already quite good. It won't be free but it won't be expensive either.
If you like ruby you'll like smalltalk (I love both).
http://www.ambrai.com/
 
M

Michael DeHaan

Not to sound like an employee of the company or anything (I'm not It's
just that I relate to your questions and have asked the same ones so I
feel your pain), but I really suggest trying out the ambria stuff. I
also ran into this issue. Quite anoying. Ambria is in beta and is
already quite good. It won't be free but it won't be expensive either.
If you like ruby you'll like smalltalk (I love both).
http://www.ambrai.com/

Steven ---

Your examples do look nice. As far as licensing goes (seeing you
haven't defined it yet?), you might want to look at ActiveState's
model, which breeds revenue primarily from commercial support and
distribution rights while still allowing very liberal (and free!) use
as long as the runtime is not distributed.

This is awesome because it is used like wildfire in commercial
environments behind-the-scenes-and-in-development and has very good
name recognition, yet to build anything that directly generates
revenue as an external shippable product, you need to pay them money
(they also have very nice packaging tools you get for that $).

Anyhow, just my two cents. I'll probably play with your beta as I do
have an interest in at least casual exposure to a variety of
languages, as a pathological interest in shiny Cocoa GUI's.

--MPD

===

Tod> I don't know him, and haven't tried it, but
Tod> http://www.philsgaff.co.uk/index.php?p=51 discusses bundling ruby into
Tod> an app.

And better yet, it has an awesome duck banner at the top of the page!
Ducks rule!
 
N

Nick

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 main.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 first 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. RubyCocoa uses an external
framework and would be better suited for application-wrapping.

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
 
R

Ryan Platte

Nick said:
Actually, I've wrapped a number of ruby apps. If done right, ruby apps
can look just like Mac OS X applications.

Hi Nick,

Thanks for your great work bringing OS X and Ruby together.

Would you consider adding your insights to the RubyGarden page I
started on this topic some time ago?

http://rubygarden.org/ruby?BundleRubyExecutableInMacOSX

Also, would you consider starting a RubyForge project to release your
bootstrap code? Having something in a standard Ruby site would bring a
wider audience to the idea of creating self-contained OS X apps based
on Ruby.
 
N

Nick

Would you consider adding your insights to the RubyGarden page I
started on this topic some time ago?

I've intermixed your original article with the content of the post. I
think it flows ok, but probably could use a little editing.
Also, would you consider starting a RubyForge project to release your
bootstrap code? Having something in a standard Ruby site would bring a
wider audience to the idea of creating self-contained OS X apps based
on Ruby.

I'm not opposed to creating one, but I am afraid of supporting one. In
the meantime, I reposted the code on rubygarden and made it public
domain. I hope it will serve some people well.

Nick
 
M

Mikkel Bruun

Hello,

I seem to have problems using the boot.cpp you posted earlier. Being a
total c/c++ (and mac development) newbie it doesnt surprise me...
I encounter the following problems when linking:

feisty:~ mb$ g++ -c -I /opt/local/lib/ruby/1.8/powerpc-darwin/ -x
objective-c++ -framework Cocoa boot.cpp
g++: -framework: linker input file unused because linking not done
g++: Cocoa: linker input file unused because linking not done

feisty:~ mb$ g++ -o boot -L/opt/local/lib/ruby/1.8/powerpc-darwin/
-lruby-static -framework Cocoa boot.o
ld: Undefined symbols:
_ruby_init
_ruby_options
_ruby_run

Any suggestions??

Thanks in advance

Mikkel
 
N

nobu.nokada

Hi,

At Thu, 23 Dec 2004 05:47:01 +0900,
Mikkel Bruun wrote in [ruby-talk:124334]:
feisty:~ mb$ g++ -c -I /opt/local/lib/ruby/1.8/powerpc-darwin/ -x
objective-c++ -framework Cocoa boot.cpp
g++: -framework: linker input file unused because linking not done
g++: Cocoa: linker input file unused because linking not done

Seems -framework option shouldn't be used to compile.
feisty:~ mb$ g++ -o boot -L/opt/local/lib/ruby/1.8/powerpc-darwin/
-lruby-static -framework Cocoa boot.o
ld: Undefined symbols:
_ruby_init
_ruby_options
_ruby_run

Try surrounding `#include "ruby.h"' line by `extern "C" {' and
'}'.
 
M

Mikkel Bruun

Hi,

At Thu, 23 Dec 2004 05:47:01 +0900,
Mikkel Bruun wrote in [ruby-talk:124334]:
feisty:~ mb$ g++ -c -I /opt/local/lib/ruby/1.8/powerpc-darwin/ -x
objective-c++ -framework Cocoa boot.cpp
g++: -framework: linker input file unused because linking not done
g++: Cocoa: linker input file unused because linking not done


Seems -framework option shouldn't be used to compile.

That did the trick!
Try surrounding `#include "ruby.h"' line by `extern "C" {' and
'}'.

Nope, im still getting

ld: Undefined symbols:
_ruby_init
_ruby_options
_ruby_run

src is now like

....
#include <Foundation/NSBundle.h>
#include <string.h>
extern "C" {
#include "ruby.h"
}
....

now these symbols are defined in ruby.h right?? im using 1.8x, is that a
problem??

Thanks for your help

Mikkel
 
N

nobu.nokada

Hi,

At Thu, 23 Dec 2004 16:46:58 +0900,
Mikkel Bruun wrote in [ruby-talk:124356]:
You need to pay attention to the order of libraries and
objects. boot.o which requires symbols in libruby has to come
before the -l option.

$ g++ -o boot -L/opt/local/lib/ruby/1.8/powerpc-darwin -framework Cocoa boot.o -lruby

BTW, shared library version doesn't work?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top