Build Swift Code#

There are several ways to build Swift code with Noctule.

Build Actions#

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

The build actions execute swift build and xcodebuild commands in the background, depending on the current project. The commands are executed with the toolchain configured in the project settings.

Enabling Build Support#

The setting Preferences… → Build, Execution, Deployment → Noctule, the Swift IDE → Build Settings → Run swift build or xcodebuild for project build tasks controls whether Noctule provides the implementation of the project’s build actions.

Because the IDE supports only one plugin or build system for building, you need to enable this setting in projects where Swift is your main language.

The setting is enabled by default if you opened a Swift Package Manager project or an Xcode project as a new project, or if you created a new Swift Package Manager project with Noctule’s wizard.

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 that 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 build actions is shown in your IDE’s own “Build” tool window, which you can open at View → Tool Windows → Build.

Every package that is cleaned or built appears as its own node in the build tree, with the output of the corresponding swift build, swift package clean or xcodebuild command.

Build Run Configuration#

The dedicated run configuration “Swift Package Build” 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 configures the fine-grained build settings. If you don’t change them, then the default values from Noctule’s directory settings are used.

Next: Executing Swift Code