Package Ruby to a standalone Mac OS X application? - ruby

I know Python has py2app. I was wondering if Ruby has anything like that. I know there is OCRA (One-Click Ruby Application builder) for Windows, but what about for Mac OS X?

Take a look at Platypus; it may do what you want.
From its homepage:
Platypus is a developer tool for the
Mac OS X operating system. It can be
used to create native, flawlessly
integrated Mac OS X applications from
interpreted scripts such as shell
scripts or Perl and Python programs.
This is done by wrapping the script in
an application bundle directory
structure along with an executable
binary that runs the script.
Edit per #XtraSimplicity in a comment: Platypus can't handle any input or output from stdin or stdout. That will rule it out in some cases.

MacRuby seems like the most likely candidate without knowing more details about what you're doing. It can make standalone native binaries.
http://www.macruby.org/ for more info.

RubyCocoa includes a script (standaloneify.rb) to package all the Ruby files your project uses into the app wrapper, and MacRuby (recommended if you're targeting 10.5+) compiles to native code and thus it's no more work making a standalone app than with Objective-C.

Compared to Windows, Ruby and Python are prebuilt for Mac OS X, so the easiest way might be using Cocoa with Ruby. You can get good information out of the book Programming Cocoa with Ruby.

Related

How to deploy Gtk+ app on Mac?

Is there a more or less official way for Gtk+ applications to create regular OS X .app with all needed resources and libraries, placed in correct way?
Pretty much everyone does their own thing. Check out the outdated (read: not really maintained) bockbuild, as well as the build scripts that gedit uses for building .dmg.
https://github.com/mono/bockbuild
https://git.gnome.org/browse/gedit/tree/osx
This is something I'd love to see migrated to a configure/automake addition with dmg targets.
the easiest way to deploy a GTK based app on macOS:
How to deploy GTK based app on Mac OS X?
You should read it.

Deploying Ruby-Tk app on OS X

I'm looking for a straightforward way to deploy a standalone Ruby-Tk desktop app on OS X. All existing options for deploying desktop Ruby GUI apps on the Mac (e.g. standaloneify.rb) assume that you are using RubyCocoa or MacRuby, and are tightly bound to Xcode/Interface Builder project structure; or, alternatively, that you are wrapping a simple script via Platypus that does not involve deploying the entire Ruby runtime. None of the other existing options that I've found--rubyscript2exe, ocra, crate--support the Mac and/or support Ruby 1.9.
I'm hoping that someone can point me to a shell script or Ruby script that does the following:
Tracks all dependencies/gems in an app.
Copies the Ruby interpreter and dependencies into an application bundle.
Runs install_name_tool on the Ruby interpreter and all dylibs to make them portable.
The application bundle can either be something created by Platypus, use a Cocoa stub launcher, or even a shell script--I know how to handle those. The problem I'm having is getting the Ruby runtime wrapped in a portable way.
There's a rakefile at http://weft-qda.rubyforge.org/svn/trunk/weft-qda/rake/rake_osx.rb that encompasses the tasks that I'm looking to achieve, but this rakefile is part of a larger build structure that I can't get running on my Mac. I'm not familiar enough with rakefile structure to refactor this into a simple script that I can run, either via "ruby rake_osx.rb" or even "rake".
If someone can suggest to me how to modify this rakefile to run independently, or point me to another example project, or even share some code, I would be grateful. The project I am working on is better suited for Ruby than Python (better library support in Ruby), but I am not going to invest time in it if deployment won't work. (Python has a much richer tradition of deployment tools than Ruby, something I'v never quite understood.)
This is a bit late after the fact, but in classic fashion, since I could not find a desktop app deployment tool for Ruby-Tk on the Mac, I wrote my own:
ruby2app
ruby2app is a simple command-line tool, inspired by similar Mac tools like py2app for Python, that bundles a Ruby script with the Ruby runtime into a standalone Mac application. It reads a basic configuration file to find the appropriate Ruby installation, compiles a small C program that embeds the Ruby interpreter, copies the entire Ruby installation into the application bundle, and re-links the relevant libraries with the main executable.
It attempts to provide for the Mac what ocra and exerb provide for Windows. Hopefully this will be of use to others.

Smalltalk with GUI on Mac OS X Lion (10.7)

I need some smalltalk with GUI for my homework, and I'm running Mac OS X Lion (10.7).
I've seen that unix users usually use GNU Smalltalk and GTK+.
I've tried to install them from different versions of sources and all of them give some errors.
Then I've used MacPorts, but that installation breaks GTK+ bindings for gst.
Finally I've tried to install it using fing package manager (because GNU states that I should install everything nice) but there is no smalltalk package for 10.7 OS (though there is for previous ones).
Is there some way to use smalltalk under Mac OS Lion, or should I for example run Ubuntu on virtual machine?
You could also try Pharo, which is a fork of Squeak.
http://www.pharo-project.org/home
Uko,
Have you looked at Squeak? Its an open source version of Smalltalk which is really fun to use and is supported on most platforms.
See:
http://squeak.org/
You will need a specific SqueakVM for the Mac:
http://www.squeakvm.org/mac/
Let me know if you have any further questions...
Squeak or Pharo are real Smalltalks (unlike GNU). This means they have a Smalltalk specific IDE. IDEs were invented by the creators of Smalltalk, so whatever you think you know about IDEs, you probably don't.
My video series, Squeak from the very start, shows how to download the latest Squeak Smalltalk and get started with it. Pharo isn't any harder to install either.
http://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=view_all
You can also give the Personal Use version of VisualWorks a spin:
http://www.cincomsmalltalk.com/main/developer-community/trying-cincom-smalltalk/try-cincom-smalltalk/
I'm assuming you'll get a 7.8(.1?) version there. The OSX skin is pretty dated. I promise it's getting better. Look for 7.9 soon now.

MacRuby: How to write an app/script that generates native Mac apps?

So I'm basically trying to recreate what this app: Fluid, already does. I want to write a Ruby script, or MacRuby app that accepts a few parameters and can generate a simple native app.
Since their code is not open-sourced, I can't see how they do it. And I don't know how I would begin to accomplish something like this.
Also, I would like this script to be run on Windows (not that the user could install the generated app, but so the app could be distributed to Mac users).
How could I do something like this?
Solution:
Here is a project that does exactly the same thing that I'm trying to do. It takes an app bundle and does some string replacing on some files in the bundle. I'm going to use it as an example to imitate.
https://github.com/maccman/macgap-rb
MacRuby can already create native app bundles on OS X (it's a compiler as well as an interpreter), so in a sense there's no question to be answered here. If you want to write an app in MacRuby or Objective-C for OS X, the experience is essentially the same (though, of course, MacRuby has different command line flags for generating the final result, in this case the -deploy flag to MacRuby vs some linker invocation for ObjC). That said, nothing you write in MacRuby will run natively in Windows. Depending on the complexity of the app you have in mind, you may have to go to some cross-platform solution (like Unity) for that.
Check out Prism. It's not Ruby, but it does exactly what you describe and is open-source. One thing you'll to do is embed a web browser into a window, so look for libraries that do that. I'm assuming you'll use Cocoa for GUI since you're using MacRuby. In the end, the simplest way would be just have a window with web browser in it.

Language options for GUI applications on OS X

If I want to write applications that use the Mac OSX UI, is Objective-C the only choice that I have to take advantage of all the frameworks that Apple provides?
Can I use Java, which is installed with Mac OS X?
I think Objective-C will provide the best coverage, yes, but if you want to consider portability and the possibility of getting your applications running under Windows and/or Linux, then choose Qt and C++.
The frameworks for native UI applications on Mac OS X (collectively known as Cocoa) are written in Objective-C so Objective-C is probably the best choice for writing your own applications, although there are bindings for Python and Ruby.
There are other toolkits that can be used (Mac OS X is a *nix system after all) but unless you are writing cross-platform apps, most people will advise you to use Objective-C and Cocoa.
MacRuby, an implementation of Ruby 1.9 on top of Mac OS X Objective-C runtime and Foundation framework, is another way to go.
You still need a deep knowledge of Cocoa and a good understanding of Objective-C.
It will be provided with Mac OS X 10.7 Lion as a private framework. It already integrates very well in XCode 4 workflow, with templates for all type of application (including windowed, it goes without saying).
(MacRuby makes RubyCocoa, the Cocoa binding for Ruby, obsolete.)
The JVM for Java under Mac OS X is no longer provided by Apple, but by Oracle (see here).
I guess Objective-C is the best choice for native OS X Applications. But if you want your Applications to run under other OSs (like Windows or Linux), you'll most likely use C++ and some GUI-Toolkit which supports all of them.
If you come from the Perl world, here is Sherm's CamelBones too.

Resources