Swift
Nuclide has limited, built-in support for Swift and the Swift Package Manager.
Nuclide’s built-in Swift support is not endorsed by Apple. The Swift logo is a registered trademark of Apple Inc.
Configuring Nuclide for Swift Package Development
Nuclide will attempt to find a Swift executable automatically:
- On macOS, it will use the latest version of Swift installed at
/Library/Developer/Toolchains/swift-latest.xctoolchain
. - On Linux, it will find a Swift executable based on your
$PATH
.
You may use a specific version of Swift by setting the Swift Toolchain Path in the Nuclide settings:
- Open the Nuclide Settings tab either by pressing
Cmd+,
(Ctrl-,
on Linux) or by going toPackage | Settings View | Open
. - Select Packages from the list at the left, and search for
nuclide
. - Click on the Settings button for the
nuclide
package. - Scroll down until you find
nuclide-swift
, and enter the Toolchain path in the Swift Toolchain Path text box.
Nuclide uses SourceKitten to provide features such as Autocomplete.
On macOS, Nuclide expects to find a SourceKitten executable at /usr/local/bin/sourcekitten
. Installing SourceKitten via Homebrew, by running brew install sourcekitten
at the command line, places it in this location.
Unfortunately, SourceKitten is not yet available on Linux. As a result, features such as Autocomplete are only available on macOS.
You may configure Nuclide to use a SourceKitten executable at a different location by setting the Path to SourceKitten Executable in the Nuclide settings.
- Open the Nuclide Settings tab either by pressing
Cmd+,
(Ctrl-,
on Linux) or by going toPackage | Settings View | Open
. - Select Packages from the list at the left, and search for
nuclide
. - Click on the Settings button for the
nuclide
package. - Scroll down until you find
nuclide-swift
, and enter the custom SourceKitten path in the Path to SourceKitten Executable text box.
Features
Swift integration in Nuclide provides you with productivity features such as:
Building and Testing Swift packages
The Task Runner toolbar is used to build and test Swift packages. To open the Task Runner toolbar, click on the Toggle Task Runner Toolbar button in the Nuclide toolbar or search for Nuclide Task Runner: Toggle Swift Toolbar
in the Command Palette.
See the Task Runner Swift guide for how to build and test Swift packages.
Autocomplete
Once you have built your Swift package via the Task Runner’s Swift toolbar, Nuclide will be able to provide autocompletion suggestions for Swift source code.