CamelBones

An Objective-C/Perl bridge framework

 
 
Home / Documentation / Getting Started / Hello, world!
 
 

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 and creating your new project. In the "New Application" dialog box, choose "Cocoa Application" in the section "Perl" from the list of project types. 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
 

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.

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 Text" 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 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 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.

Run your application by clicking the "Build and Run" button.

What's next?

Next: Responding to Events