Swiftpack.co - apple/swift-syntax as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by apple.
apple/swift-syntax xcode11-beta1
A set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code.
⭐️ 2,018
🕓 Yesterday
iOS macOS watchOS tvOS macCatalyst
.package(url: "https://github.com/apple/swift-syntax.git", from: "xcode11-beta1")

SwiftSyntax

SwiftSyntax is a set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code.

Note: SwiftSyntax is still in development, and its API is not guaranteed to be stable. It is subject to change without warning.

Adding SwiftSyntax as a Dependency

Trunk Development (main)

The mainline branch of SwiftSyntax tracks the latest developments. It is not an official release, and is subject to rapid changes in APIs and behaviors. To use it, add this repository to the Package.swift manifest of your project:

// swift-tools-version:5.7
import PackageDescription

let package = Package(
  name: "MyTool",
  dependencies: [
    .package(url: "https://github.com/apple/swift-syntax.git", branch: "main"),
  ],
  targets: [
    .target(name: "MyTool", dependencies: [
      .product(name: "SwiftSyntax", package: "swift-syntax"),
    ]),
  ]
)

Mainline SwiftSyntax also includes

  • SwiftParser for natively parsing source code
  • SwiftOperators for folding SwiftSyntax trees containing operators
  • SwiftSyntaxBuilder for generating Swift code with a result builder-style interface

Releases

Releases of SwiftSyntax are aligned with corresponding language and tooling releases and are stable. To use them, add this repository to the Package.swift manifest of your project:

// swift-tools-version:5.7
import PackageDescription

let package = Package(
  name: "MyTool",
  dependencies: [
    .package(url: "https://github.com/apple/swift-syntax.git", exact: "<#Specify Release tag#>"),
  ],
  targets: [
    .target(name: "MyTool", dependencies: [
      .product(name: "SwiftSyntax", package: "swift-syntax"),
    ]),
  ]
)

Replace <#Specify Release tag#> by the version of SwiftSyntax that you want to use (see the following table for mapping details).

Xcode Release Swift Release Tag SwiftSyntax Release Tag
Xcode 14.0 swift-5.7-RELEASE 0.50700.0
Xcode 13.3 swift-5.6-RELEASE 0.50600.1
Xcode 13.0 swift-5.5-RELEASE 0.50500.0
Xcode 12.5 swift-5.4-RELEASE 0.50400.0
Xcode 12.0 swift-5.3-RELEASE 0.50300.0
Xcode 11.4 swift-5.2-RELEASE 0.50200.0

Documentation

Documentation can be found in the following places:

  • For the parser: Sources/SwiftParser/SwiftParser.docc
    • You can either directly view this documentation on GitHub or build a documentation bundle by opening the project in Xcode and clicking Product -> Build Documentation
  • General documentation: Documentation
  • Examples of using SwiftSyntax: Examples.

Contributing

Start contributing to SwiftSyntax see this guide for more information.

Reporting Issues

If you should hit any issues while using SwiftSyntax, we appreciate bug reports on GitHub Issue.

License

Please see LICENSE for more information.

GitHub

link
Stars: 2018
Last commit: Yesterday
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.50700.1
7 weeks ago

This is the 0.50700.1 release of SwiftSyntax that vends the parser library (_InternalSwiftSyntaxParser.dylib) as a binary framework dependency on macOS.

To use this snapshot add the following dependency to your Package.swift:

.package(url: "https://github.com/apple/swift-syntax", branch: "0.50700.1")

Or, if using a swift-tools-version ≤ 5.4:

.package(url: "https://github.com/apple/swift-syntax", .branch("0.50700.1"))

⚠️ Important: This release of SwiftSyntax is incompatible with the parser library included in the swift-5.7-RELEASE toolchain. On Linux, download a recent swift-5.7-DEVELOPMENT-SNAPSHOT toolchain to use this SwiftSyntax version. On macOS, this version of SwiftSyntax is compatible with any recent Swift or Xcode toolchain because it includes the parser library as a binary dependency.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics