talira

SourceKitten

An adorable little framework and command line tool for interacting with SourceKit

open sourceMITfree

SourceKitten is a Swift framework and command-line tool that talks to Apple's SourceKit to parse the Swift AST, extract documentation comments from Swift and Objective-C projects, get syntax and structure data for a Swift file, index it, format it and generate code completions, printing the results as JSON. SwiftLint, Jazzy and Sourcery are built on it. It runs on macOS with Xcode and on Linux with a Swift toolchain.

Ways to install

Problems it solves

  • extract the doc comments from my Swift code as JSON to build documentation
  • get the structure of a Swift file from a script without writing a parser
  • build a Swift linting or code generation tool on top of SourceKit

Features

  • Swift and Objective-C documentation as JSON
  • Swift structure, syntax and index information as JSON
  • code completion options
  • Swift file formatting
  • raw SourceKit requests
  • installs with Homebrew, Swift Package Manager, Bazel or a .pkg

Limitations

  • On Linux it needs SourceKit at /usr/lib/libsourcekitdInProc.so or a path set in LINUX_SOURCEKIT_LIB_PATH2

Capabilities

Has a command line toolplan not known