How akaduality/build-graph-for-xcode works
Project Type & Purpose
• This is a modular, multi‐package macOS desktop application written in Swift.
• Purpose: visual analysis of Xcode build times by parsing build logs (.xcactivitylog) and the Xcode target-graph, then rendering a module‐dependency graph with interactive filters.
High-Level Modules (components)
• App (App/App)
• macOS application entry point (AppDelegate, MainWindow, Menu, Storyboards)
• Glue between the UI package, the Domain package, and peripheral services (e.g. Firebase in Release target)
• UI (UI/Sources)
• Projects panel (left pane): project discovery & selection
• Details panel (center pane): graph drawing, uses Domain layers for graph model → renders via AppKit/Storyboard
• Filters panel (right pane): filter configuration for build steps, modules, time ranges
• UI implements an MVP/MVC‐style pattern (Presenters, StateViewControllers)
• Domain (Domain/Sources)
• BuildParser: reads and parses .xcactivitylog files into domain events, durations, concurrency layers
• GraphParser: reads Xcode’s target-graph.txt to extract module dependencies
• Snapshot: sample build snapshots for testing/demo
• Domain is a pure Swift library with no UI, organized into subpackages: Parsing, Layers, Domain models, Storage
• XCLogParser (XCLogParser/Sources)
• Low‐level log‐parsing toolkit (lexer, parser, reporters) leveraged by Domain.BuildParser
• Independent Swift package, optimized to avoid String allocations
External Systems & Data Sources
• Xcode (external build process) → produces DerivedData folder containing .xcactivitylog and target-graph files
• Firebase (used in Release target only for analytics/crash reporting)
Dependencies & Data Flows
• User launches App → AppDelegate initializes UI modules
• UI.ProjectsPresenter invokes Domain.ProjectsFinder to enumerate projects in DerivedData
• Upon project selection:
• Domain.GraphParser parses the target‐graph file → returns module dependency graph
• Domain.BuildParser uses XCLogParser under the hood to parse .xcactivitylog → emits build events and timing
• Domain.Layers build layered representations (timeline, vertical lines, modules layers)
• UI.DetailsController takes the domain layers → draws the graph in the center pane
• UI.FiltersController manipulates Domain.FilterSettings → re‐asks Domain to re‐filter layers
• App coordinates reading/writing settings (e.g. image export, snapshot save services)
Key Architectural Patterns & Principles
• Layered Architecture: UI → Domain → XCLogParser → File System
• Separation of Concerns:
• UI package is strictly responsible for presentation and user flow
• Domain package is purely business logic & parsing, no UI dependencies
• XCLogParser is an independent utility library (lexer & parser)
• MVP/MVC in UI with Presenters and StateViewControllers for each screen/state
• Swift Package Manager organizes each module as its own package with Package.swift