CamelBones

An Objective-C/Perl bridge framework

Getting Started - Hello, world!

The classic "Hello world!" program is more than just a tired introduction - it's one of the simplest possible programs that produce output. That makes it useful for testing your installation of the CamelBones framework. A more complicated program has a greater chance of having bugs of its own, making it difficult to be certain of the cause of any problems that crop up.

So, let's see if that copy of CamelBones you just installed is really working!

1. Create a project

Screen shot of "New Project" dialog
"New Project" dialog
click to enlarge

Begin by starting Xcode (if you're using Panther) or Project Builder (if you're using 10.1 or Jaguar) and creating your new project. In the "New Application" dialog box, choose "Cocoa Application" in the section "Perl" from the list of project types. If you're using 10.1, choose "Cocoa Application (10.1)". After that, choose a name for your project ("Hello" would be a good choice for this one), and where you'd like to store the project files to finish the project creation.

2. Find and open the main window NIB

Screen shot of Resources group in Xcode
Resources group in Xcode
click to enlarge

If you're using Xcode, expand the "Hello" item in the "Groups & Files" outline to the left by clicking on its disclosure triangle. Then select the "Resources" item under "Hello" by clicking once on it. Notice that selecting items in the outline affects the list of files that appear in the main part of the window - this can be a big help as more files are added to your project. Open "MainWindow.nib" in Interface Builder by double-clicking it, either in the list or the outline.

Screen shot of Resources group in Project Builder
Resources group in Project Builder
click to enlarge

If you're using Project Builder, the left part of the window contains several tabs. Choose the "Files" tab to show an outline view of the files in your project that's similar to that found in Xcode. Expand the "Resources" group in this outline, and double-click the "MainWindow.nib" item. Unlike with Xcode, there is no list of files in the main part of the window, so double-clicking in the outline is the only way to open a file.

3. Add a text label to the main window

Screen shot of text palette in IB
Text palette in Interface Builder
click to enlarge

In Interface Builder, select the "Cocoa Views" ("Cocoa Text" in the Xcode version of IB) palette, and drag a text label from it onto the main window. There are several sizes of label to choose from - take your pick.

Screen shot of editing text label in IB
Editing the text label in IB
click to enlarge

Double-click the text label in the main window to edit the text within it, and change the text to - wait for it - "Hello, world!" Or, change it to something else, if you're feeling particularly creative today. I won't be offended, I promise.

Be sure to save the changes you've made before switching back to Project Builder or Xcode.

4. Build and run your application

Screen shot of "Build" and "Build and Run" buttons
Xcode toolbar buttons
click to enlarge

Build your application by clicking the "hammer" button in Project Builder or Xcode's tool bar. It may seem odd at first that you'd have to build your application - Perl is not, after all, a compiled language. But, your Perl code is stored in the application bundle as a resource, and the build process does more than just compile code - it also checks for modified resources that need to be copied into the application bundle.

Screen shot of "Build" and "Build and Run" buttons
Project Builder toolbar buttons
click to enlarge

Run your application by clicking the "Build and Run" button. In Xcode, this is the "hammer and green arrow" button, and in Project Builder it's the "hammer and monitor" button.