$ show SolaWing/xcode-build-server
This repository implements a Build Server Protocol (BSP) server that integrates Xcode builds with language servers like sourcekit-lsp. It parses Xcode build logs (either from IDE builds or xcodebuild) to extract compiler flags and serves them via BSP to provide accurate code completion, navigation, and other language features for Swift, C, C++, Objective-C, and Objective-C++ projects. The server operates in two modes: 'xcode' mode automatically monitors build logs via a post-build script or file watching, and 'manual' mode processes build logs on demand. Key components include a robust compilation database handler, a parser for Xcode's proprietary xcactivitylog binary format, and a log parser that handles various Xcode build output formats. The project is actively maintained with recent commits and shows no significant technical debt.
The LLM identified 3 files worth highlighting for reuse:
Manages compilation flags from build logs, providing efficient lookup and inference for source files. Handles complex scenarios like file lists (@filelist), filters unsupported flags, and intelligently infers flags for new files by referencing similar existing files in the same or parent directories. The module is self-contained, uses only standard library, and exposes a clean API (GetFlags, GetWorkingDirectory, InferFlagsForSwift) that could be reused in any tool needing to work with compilation databases.
Parses Xcode's proprietary xcactivitylog binary format to extract compilation-related text sections. Implements a custom tokenizer for the binary format and filters for known compilation markers (like 'CompileSwiftSources', 'CompileC'). This self-contained module solves the niche problem of reading Xcode's internal build logs without relying on any external dependencies, making it reusable in other tools that need to process xcactivitylog files.
Parses Xcode build output (both raw xcodebuild logs and xcactivitylog) into a structured compilation database format (JSON array of command objects). Handles multiple compilers (swiftc, clang), various build steps (precompiled headers), and log format variations. The parser is robust, uses only standard library, and can be invoked as a library or script. Its core XcodeLogParser class is decoupled from the rest of the system via a logger callback, allowing easy integration into other build tooling pipelines.