In the Settings/Preferences dialog box, expand the Build, Execution, Deployment node and select the Swift option of the left pane.
On the right pane, specify the Swift SDK home directory (on macOS the default is /Library/Developer/Toolchains/swift-latest.xctoolchain, and on Linux it’s empty): In the text field, type the path to the Swift SDK directory or click the button to choose.
If you want to enable the Swift debugger, select the Use Swift debugger check box. Note: currently you need to switch-off the debugger when you are working with non-Swift programs.
Creating Swift project using project template
To create a new Swift project using a project template, do the following:
On the main menu, choose the File | New Project option.
In the dialog that opens, under Other node of the left pane select Swift Executable.
Go to the right pain. In the text field specify the path to the project and the project's name. Do nothing to use the default settings.
Click create to proceed.
Upon the system prompt, tell CLion where to open your project: in the current or new window.
The resulted CMake configuration file may look as follows:
Using CMake Live templates
Since CLion is based on CMake project model you can create a project using a special CMake live template that adds a Swift build target: where the SWIFT_SDK variable expands to the value specified in the settings.
Supported features
With Swift plugin enabled, CLion supports the set of the following features:
Parse/resolve classes in project and standard library. Note that non-standard libraries are not resolved yet in Swift plugin for CLion.