In this short tutorial, you will create and run your first Swift project using Tifig.

Goals

  1. Create a project
  2. Make changes
  3. Run the project

1. Create a Project

There are several ways to open the New Swift Project wizard. Choose one of the following:

  • Right-click in the Project Explorer window. Select New/Swift Project.
  • Choose File/New/Swift Project from the main menu.
  • On the welcome screen (see Configure Tifig), click on Create Swift Project.

After doing so, the wizard shown below opens:

New Project Wizard

Here, you have to choose a name for your project. We chose Hello_Tifig, but you can choose whatever name you like.

The wizard has checked the box for using the default location, which creates a folder with your project name in your current workspace. If you want, you can change this by unchecking the box and providing an alternative location.

Tifig differentiates between three project types:

  • Empty
  • Executable
  • Library

For our example, we will stick with the executable project.

Click Finish to return to the main window, which now looks as follows:

Initial Project

As you can see, the parts that have changed are highlighted in red rectangles and numbered from 1 to 3. We will discuss each of the changes separately below.

  1. Project File Structure

    If you have a closer look at the Project Explorer window, you can see that Tifig has created some files and folders for you.

     .
     └── Hello_Tifig
         ├── Package.swift
         └── Sources
             └── Hello_Tifig
                 └── main.swift
    
    

    The main folder has the name of your project. In our case, this is Hello_Tifig. In it, a Sources/Hello_Tifig folder has been created, containing the main.swift file. This file will be our main focus in this tutorial.

    In addition, your project folder contains a Package.swift file. This file will be further discussed in the Using the Swift Package Manager tutorial.

  2. The main.swift File

    The name of this file is not set by accident. The main.swift file is used as the entry point of your entire application. By default, the newly created file has the following content:

     print("hello, world")
    

    As you probably would have guessed, this application prints hello, world to your console when being executed.

  3. Console Output

    Having clicked on Finish in the New Swift Project wizard, Tifig has already started working for you. On the bottom, you can see the output of the Swift compiler. If you have configured your toolchain correctly, you should get something similar to the following:

     Build Mode: auto
     Command: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift build
     Compile Swift Module 'Hello_Tifig' (1 sources)
     Linking ./.build/x86_64-apple-macosx10.10/debug/Hello_Tifig
     Exit Value = 0
    

    If your console does not show this, it is possible that the indexer is still running. You can check that by looking at the bottom right corner of Tifig. If the indexer is still running, you will see the word Indexer and a blue progress indicator (see screenshot above).

2. Make changes

You can make changes to your files by just typing them in the main.swift window. Saving your changes will trigger the Swift compiler to start a new build, which you can see in your console output. In our example, we replaced print("hello, world") with print("Hello Tifig"), matching our project name. Tifig now looks as follows:

Changed Project

3. Run the Project

To run your project, you can do one of the following:

  • Click on the green Run Button in the toolbar on the top.
  • Choose Run/Run from the main menu.

If everything works out, the console output should display Hello Tifig, as in the screenshot below:

Running Project

Summary

Congratulations, you have just created, changed and run your first Swift project in Tifig. Of course, this example shows the most simple project, having no other dependencies than the Swift standard library and only consisiting of a single file. To find out how you can manage dependencies using the Swift Package Manager, go to our next tutorial.