Build Swift Code#

There are several ways to build Swift code with Noctule.

Build Actions#

Some JetBrains IDE, most notably IntelliJ IDEA and CLion, provide a Build menu with actions “Build Project” and “Build Module”.

The build actions execute swift build commands in the background. The commands are executed with the toolchain configured in the project settings.

Enabling Build Support#

Setting Preferences… → Build, Execution, Deployment → Noctule → Build Settings → Run swift build for project build tasks controls if Noctule should provide the implementation for the project’s build actions.

Because the IDE only supports one plugin or build system to build, you need to enable this setting in projects where Swift Package is the main system. If you created the project with the “New Project” wizard of Noctule 1.11.0 or later, then this setting is enabled by default.

Building all Swift Packages#

Execute Build → Build Project to build all Swift Packages in the project.

Correspondingly, Build → Rebuild Project first invokes swift package clean for every Swift Package before the build is executed.

To build Swift Packages contained in a module, invoke Build → Build Module. The current selection (for example, a file) is used to determine the module and the contained Swift Packages.

Building a Single Swift Package#

To build a specific Swift Package, select a file or editor which belongs to the package. Then select Build → Build Swift Package from the menu to launch the build. Correspondingly, Build → Rebuild Swift Package first cleans the package with swift package clean before building it.

Viewing Build Logs#

The output of the swift build commands are shown inside the Noctule tool window. You can find it in the lower left corner of the main window or at View → Tool Windows → Noctule Logs.

Each build action is shown in a separate tab inside the Noctule tool window. If an error is detected in the build output, then the Noctule tool window is activated. Otherwise, the build log is not shown unless the user opens it.

Build Run Configuration#

The dedicated run configuration “Swift Build Package” allows building Swift Packages from the IDE.

Settings#

Swift toolchain
The toolchain used to build the package. You only need to change this setting if you want to build with a different toolchain than the rest of the project.
Package directory
The Swift Package directory. The swift build command is executed in this directory.
Product
If you’d like to build a specific product, then choose it here.
Program arguments
If you would like to pass additional arguments to the swift build command, then enter them here.
Environment variables
Here, you can define environment variables which are passed to the swift build command.
Build Settings
This section allows configuring the fine-grained build settings. If you don’t change them, then the default values from Noctule’s directory settings are used.