Quick Start: Write a Swift report application

You can write, compile and execute your report program from within Genero Studio. This guided quick start illustrates how you should organize a Genero Studio project to manage the files for a Swift-based report application.

Before you begin, you must have:
In this quickstart, you complete the steps to organize a project, where the report application will be handwritten in Swift. You will set up a project, add and organize source files, create a data schema, create a report from a template, and test the application. The Swift source and a sample data schema will be provided for you. You would follow these same steps when writing your own Swift report application.
Warning:

If you plan on generating your application's data model, start with Quick Start: Generate a Swift report application instead.

  1. Select File > New ... > Swift > Simple Swift Project (.4pw), then click OK.
  2. Rename the default group node to Sales.
    This group node will hold nodes for your application and for your reports.
  3. Create the file to hold your report application code.
    This file will contain the source code for the report application; we provide you with a simple program for this quick start.
    1. Fully expand the project to display all nodes in the tree.
    2. Right-click on the Application node and select New File > Swift > Swift main (.swift).
    3. Name the file main.swift and save it in the application node.
    4. Replace the content of the file with the source code found here.
    5. Save your changes.
  4. Rename your application node to match the fully qualified name (class name).
    1. Right-click on the Application node and select Rename.
    2. For our example, enter "Sales".
  5. In the application node's Linker options, ensure the following exists
    -I "$(ProjectDir)/bin" -L "$(ProjectDir)/bin"  -I "$(GREDIR)/lib/swift" 
    -L "$(GREDIR)/lib/swift" -lgre
  6. Save your project.
    1. Click in the Project view, to give it focus.
    2. Select File >> Save untitled.4pw as ....
    3. Provide your project with a name (such as Sales.4pw) and save it in your project directory.
  7. Create the data schema file.
    For Swift applications, the data schema is created by hand. You cannot generate the file.
    1. Rename the default library node as Reports.
    2. Select File > New ... > Other Files > With no Extension.
    3. Copy the code provided here and paste it in the file.
    4. Save the file as Sales.xsd in the Reports library node.
  8. Compile the program.
    1. Right-click the application node and select Build.
      The program executables are created and placed in the /bin sub-directory.
  9. Create a simple list report.
    1. Select File > New > Report from template > Simple List (PULSE), then click OK.
      The New Report From Template wizard opens, and the Schema Association page displays.
    2. In the Schema Location field, select the Sales.xsd data schema you created in an earlier step. Click Next.
      Remember, we are keeping this report simple for the quick start only!
    3. On the Add Fields page, select one or more fields in the Available Fields pane and add them to the Selected Fields pane. When you have at least one field selected, click Next.
    4. On the Variables page, enter your name (or any string) in the Value column for the organizationName placeholder. Click Finish.
    5. Select File > Save untitled1.4rp as ... and name the file SalesList.4rp. Save it in your project directory. Add the file to the Reports node of your project.
    6. Save the changes to the project.
  10. Execute the program. Right-click on the application node and select Execute.