Development with cappuccino beta 0.7

This week-end, the guys at released the beta 0.7 of cappuccino, a javascript framework that enable every one to build web applications. So the cappuccino community was busy at installing this release for testing and fun.

Installing cappuccino 0.7 beta

In order to work with the beta 0.7 of cappuccino, you can choose the "git" way or be a little lazy. It's the way I have choosen this time because I didn't know the git way and had not this tool installed on my MacBook Pro ;-). If you choose the other way, it's described below too.

Downloading a zip or tar file from the project page

You can go to the cappuccino project and click on the "download" button. Then choose either a zip or a tar file. Uncompress the downloaded file and run the rake installer.

If you have not played with ruby before, you will need to install the "plist" package for ruby. This is done automatically for you by the installer. I had a little problem since the installer failed on a missing document for the plist package. If this happen to you also, don't worry, just relaunch the installer and the second time, rake will found the plist package. You better install it first like this:

$ sudo gem install plist

Compile the source

To build in release mode and to install the tools in a “virtual environment” in the Build folder that you can optionally place in your paths.

$ cd /path/to/cappuccino_07beta/280north-cappuccino-07b $ rake release $ rake install

You may decide to build with debugging flags turned on

$ rake debug

To removes all files

$ rake clobber

To only remove temporary files

$ rake clean

Modify your PATH to use the developper tools

Edit your .bash_profile file

$ cd $ emacs .bash_profile

Adapt the path to reflect the directory where you decided to compile the cappuccino 0.7 beta

export PATH=$PATH:/Users/philippe/Desktop/cappuccino_07beta/280north-cappuccino-07b/Build/Release/env/bin

Edited (2009/04/30) : Since you are editing your bash_profile file, add these lines too. OBJJ_HOME is the directory where all your Objective-J tools and frameworks will be installed. STEAM_BUILD is the directory where all Cappuccino files will be compiled. GIT_EDITOR let you use the editor of your choice.

export OBJJ_HOME=/usr/local/share/objj export STEAM_BUILD=/Users/philippe/objj_build export GIT_EDITOR="mate -w"

Source your file to load its content.

$ . .bash_profile

Verify your PATH environment variable

$ env PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:.:/path/to/cappuccino_07beta/280north-cappuccino-07b/Build/Release/env/bin

Using git tool to install cappuccino and contribute to the project

This is the best way to use if you decide to be a cappuccino contributor and want to fix bugs or develop for the framework. Thomas Balthazar from just posted a webcast explaining all the process. For the time beeing, you can also copy an paste these lines in a terminal window.

# remove old install: sudo rm /usr/local/bin/bake sudo rm /usr/local/bin/cplutil sudo rm /usr/local/bin/nib2cib sudo rm /usr/local/bin/objj sudo rm /usr/local/bin/objjc sudo rm /usr/local/bin/objjtest sudo rm /usr/local/bin/ojtest sudo rm /usr/local/bin/press sudo rm /usr/local/bin/steam sudo rm -Rf /usr/local/share/objj rm -Rf $STEAM_BUILD # check out and switch to 0.7b branch: git clone git:// cd cappuccino git checkout -b 0.7b origin/0.7b # build and install rake release rake install # create test app capp myApp -l -t NibApplication # update branch at a later time: git pull

Edited (2009/04/30) : if after a git pull, you can not compile anymore, chances are you had a build problem like me. So the solution, for me, was to use : rm -Rf $STEAM_BUILD. But you could try one of these:

# Remove temporary files created during the build process. $ rake clean # Remove all files generated during the build process. $ rake clobber # Remove the build directory $ rm -Rf $STEAM_BUILD

What is in cappuccino 0.7 beta ?

Francisco Tolmasky will say it better than I could, you can found the announcement on the cappuccino wiki.


What I can see on my own is that we got the windows working as expected (we have now the option between the main window, usual application window and HUD windows). The project named MultipleWindows from Francisco Tolmasky that can be found on the cappuccino-demos project page. It is working very well and the problem of the main window menubar being not handle correctly is an already known bug and we can expected to have it fixed for next release. You can play with this example live on this page.


We also get the first release of the TableView (still incomplete but promising). Tom Robinson was also kind to create a test project (TableTest) that can be found on his web site. The code can be found here. This is very promising to see new components available to display application's data.

In order to better understand the TableView example, I decided to changed some behaviour (the image is now scaled in the first column, the table is created in a window) and I added some comments to the code. The main key to know in order to follow the code is that the TableView is just handling the display of data. The class depends on a "datasource" object that will provide the raw number and for each row, the data for each column. The class depends also on a "behaviour" object to responde to selections. In order to separe the code, I have created two categories (this enable also to group the code in the TextMate editor and expand/shrink the display of long source code).

The modified source code can be found here. The live project can be found here.


What's this ? Well a nib file is an Apple Interface Builder file that contains the description of a Cocoa application. Since cappuccino is reusing the same framework spirit than Cocoa or GnuStep (these beeing coded in Objective C), we have now a tool that is able to transform a "nib" file intow a "cib" file.

It is possible for example to create a new application using the capp tool that will use a nib/cib file. Create a directory named "myApp1" in the current directory and all the files required for a deployment

capp myApp1 -t NibApplication

During development, you may use the option -l to create symbolic links to the framework (this will spare disk place)

capp myApp1 -l -t NibApplication

If you launch the application you will see that target/action is supported (the slider send message to the text field).

You can found a more complicated test application in the folder named "NibApp". In order to have it work you must run the nib2cib application (the file from the project has to be upgraded). cd /path/to/cappuccino_07beta/280north-cappuccino-07b/Tools/NibApp nib2cib MainMenu.xib

Copy the "Frameworks" in the folder, you can now open the file "index.html" in your favorite web browser (say Safari 4.0 beta or Firefox 3). By the way, I have also tested successfully cappuccino 0.7b on the brand new Microsoft Explorer 8.0 on Windows XP.

For the curious, a cib is just a 280NPLIST stream (remember from the tutorial on serialization, the one you can create/read with a CPKeyedArchiver)

more MainMenu.cib

Using capp

If you ask yourself where are the templates located, it is in the Templates directory.

cd /path/to/cappuccino_07beta/280north-cappuccino-07b/Build/Cappuccino/Tools/objj/lib/capp/Resources/Templates ls Application NibApplication ThemeDescriptor

Create an usual "Hello world!" application (no nib/cib file based). It is the same as using "-t Application".

capp myApp2

cappuccino 0.7b introduce the option to get theme. To generate a starter project with theme use this command.

capp myApp3 -t ThemeDescriptor

What's next ?

So this seems to be a good advancement and I am expecting to see big things in release 0.8 or with the release of Atlas ;-)

Copyright © 2009 - Philippe Laval. Cappuccino and Objective-J are registered Trademarks of 280 North.