
This simple application doesn show much about Rub圜ocoa, but it gives a glimpse of the power of the Cocoa framework. Your application should now run it will look like Figure 21-9.Ī compiled, doubleclickable version of the application will be found in your project build folderusually within the project subfolder. Well use the control called System Font Text: drag this control into your application window.ĭouble-click the new text field in the application window and type "You are a trout!"įor completeness, go through the menus in the menubar and change "New Application" to "Tiny The visible controls are all text fields, with only slight differences between them. Select the Text palette in the palette window. Rub圜ocoa Application" in the inspectors Window Title field (you need to select the "Attributes" tab to see this field).Īdd a text label to the application window. Select the new application window and set the applications title. Our destination Interface Builder screenshot The screenshot in Figure 21-8 shows what wee going to do to our new application window (seen in the upper left).įigure 21-8. If the inspector is not open, select Show Inspector from the Tools menu. Youll also see a palette window with a selection of GUI objects a nib document window named MainMenu.nib (English), containing classes, instances, images and sounds and an inspector. You get a new application window, into which you can drag and drop GUI widgets, and a menubar labeled MainMenu.nib (English)MainMenu. Open the NIB Files group and doubleclick MainMenu.nib to open Interface Builder. For a simple application, this is all the code you need. The Cocoa-Ruby project template comes with two files: main.m (an Objective-C file) and rb_main.rb (a Rub圜ocoa file).

XCode will create a project that looks like Figure 21-7. Choose "Cocoa-Ruby Application" from the "New Project" list, hit the Next button, give your project a name and location on disk, and click Finish. Start the Xcode application and create a new project from the File menu. Heres how to create a simple application with Interface Builder: In fact, it takes longer to explain what to do than to do it. Interface Builder is very powerful: you can create simpleĪpplications without writing any code. Rub圜ocoa is a free download, and the Cocoa development tools are on the Rub圜ocoa creates real OS XĪpplications and provides a GUI interface for building GUIs, as opposed to other libraries, which make you define the GUI with Ruby code.

Use the Mac OS X Cocoa library along with Rub圜ocoa and the Interface Builder application. You want to create a native Mac OS X program with a graphical user interface.
