SwiftSyntax is now a Swift package manager package that is being developed in its own repository at https://github.com/apple/swift-syntax.
Using SwiftSyntax
SwiftSyntax can be configured as the dependency of any other SwiftPM project by adding
.package(url: "https://github.com/apple/swift-syntax.git", .branch("<#Specify Release tag#>")),
to you dependencies and making the build target depend on SwiftSyntax using
.target(name: "MyTool", dependencies: ["SwiftSyntax"])
<#Specify Release tag#>
needs to refer to a tagged release of SwiftSyntax. Tags will be created for every release of the compiler in the form swift-4.2-RELEASE
and for every nightly build in the form swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-25-a
. The latest tag as of now for Swift 4.2 is swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-25-a
and for Swift 5.0 swift-DEVELOPMENT-SNAPSHOT-2018-08-25-a
.
The Readme contains more detailed information on how to use SwiftSyntax.
From Swift 5.0 onwards, SwiftSyntax will no longer be included in the Open Source toolchains, giving a consistent behaviour across toolchains distributed through Xcode and swift.org.
At the moment, building SwiftSyntax on Linux is not supported but we would greatly appreciate pull requests to add that functionality. Here’s the JIRA issue for Linux support.
If you should hit any issues while using SwiftSyntax, we appreciate bug reports on bugs.swift.org in the SwiftSyntax
component.
Contributing
Building SwiftSyntax locally
SwiftSyntax still relies on the main Swift repository for code generation of the syntax tree's layout. The main swift project is thus still needed to build the most recent version of SwiftSyntax locally. Refer to swift-syntax/README.md for the steps how to do this.
Swift-CI will automatically run the code generation step whenever a new toolchain (development snapshot or release) is published and create an appropriate tag for it as described above. Referring to these tags is the recommended way to use SwiftSyntax as a dependency.
CI Integration
The @swift-ci Please test
on apple/swift command already tests SwiftSyntax. CI testing for the SwiftSyntax repository will be added in the near future, as will the automated generation of release tags.