Creating A Simple GSWeb Application

From GNUstepWiki

Revision as of 17:09, 19 January 2008; view current revision
←Older revision | Newer revision→



GNUstepWeb is a framework for creating web-based applications using Objective-C. This guide aims to provide an overview of what is required in the creation and design of a very simple web application.

It is assumed you are familiar with GNUstep, and have a working GNUstep installation, including the GDL2 and GSWeb frameworks. Pre-requisites for GSWeb application deployment should also be in place.

File Components

In building your web application you will need to create a number of files. From scratch, the following should be a rough guide to getting it working. These include the Makefile, ...

The Makefile

For a web application, a special makefile is needed: luckily it's very similar to makefiles you may have used for other kinds of project. There is currently no out-of-the-box way to have these files built for you, so you'll have to do it manually.


Initial makefile includes needed to set up the make environment should be:

include $(GNUSTEP_MAKEFILES)/common.make
include $(GNUSTEP_MAKEFILES)/Auxiliary/gsweb_wo.make

Note that the second include forces GNUstepWeb to use Apple's WebObjects naming conventions. Dropping the _wo in the included filename will enable GSW naming conventions. It is useful to decide which convention you plan to use in the application early on because changing later will involve changing the naming convention of class names in many files in your project.

The key variables used in a web application's makefile are:

used to define the project's name in the makefile, replace the {PROJECTNAME} with the name in the variables listed below
used to indicate that GSWComponents are present in the project. Normally, this is set to YES
used to identify the main class of the web application
used to indicate the list of files that are needed in the runtime bundle
contains the list of Objective-C files needed to compile the web application
lists the names of the components that will be used to create pages and other elements in the web application

The final makefile includes needed to set up the make environment should be:

-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/gswapp.make
-include GNUmakefile.postamble

The preamble and postamble files are optional includes and will not error if they don't exist. It's good practice to have these in place to allow compile-time modifications during the development process and also for others if you distribute the code.

A worked-out example of a simple GNUmakefile for a GSWeb application is:

include $(GNUSTEP_MAKEFILES)/common.make
include $(GNUSTEP_MAKEFILES)/Auxiliary/gsweb_wo.make

GSWAPP_NAME = SimpleDemo
SimpleDemo_PRINCIPAL_CLASS = SimpleDemo
#SimpleDemo_RESOURCE_FILES = Resources/SimpleDemo.eomodeld
SimpleDemo_OBJC_FILES = \
    SimpleDemo.m \
    Session.m \
    SimpleDemo_main.m \
    Main.m \

SimpleDemo_COMPONENTS = \
    Main.wo Details.wo

-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/gswapp.make
-include GNUmakefile.postamble

The name of the project is SimpleDemo, and it contains GSWComponents (the basic building blocks of GSWeb), its principal class is SimpleDemo, there are no resource files for the runtime (there is an entry, but it's hashed-out), there are five Objective-C source files, and two components. You can see that the syntax allows you to break lines using the backslash \ character as the last on the line to assist readability, especially for long lists of values, like the OBJC_FILES.

For more information as to customising this file, as well as setting up compiler options for third party libraries and includes, see the GNUstep makefile manual.


GSWeb uses a directory for every component. A component can represent a whole web page or just a part of it. It is easy to re-use pieces needed multiple times. A component contains three files they contain the HTML, the connections or bindings of your objects and additional information like the used encoding. Those files are suffixed .html, .wod and .woo. A more in-depth description of Components is available.

The application dictionary

Interface files