jerrymarino / SwiftCompilationDatabase

SwiftCompilationDatabase produces a CompilationDatabase from the Swift compiler.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwiftCompilationDatabase

SwiftCompilationDatabase produces a compile_commands.json from the Swift compiler.

For tools, like iCompleteMe, that need to invoke the swift compiler outside of a build, JSONCompilationDatabase makes it easy to get all arguments for a file.

Usage

First, build from source

make

SwiftCompilationDatabase relies on the parseable output feature of Swift. Simply run the swift compiler with parseable output enabled ( -parseable-output ), and send the result to SwiftCompilationDatabase.

In practice, this means doing a clean build so all of the frontend invocations are recorded into the database.

swiftc main.swift -parseable-output 2>&1 | swift-compilation-database

SwiftPM / Swift Build

SwiftCompilationDatabase works great with SwiftPM and swift build.

Do a clean build and pipe results

swift build -v -Xswiftc -parseable-output --build-path .build-comp-db 2>&1 | swift-compilation-database

Xcode Usage

To make a compilation database from Xcode, I recommend checking out XcodeCompilationDatabase

About

SwiftCompilationDatabase produces a CompilationDatabase from the Swift compiler.


Languages

Language:Swift 78.0%Language:Makefile 22.0%