A powerful Swift command-line tool for analyzing and visualizing code dependencies in Swift projects. UseGraph helps you understand your codebase structure, identify dependencies, and break down monolithic architectures.
- 🔍 Dependency Graph Generation - Build comprehensive usage graphs of your Swift codebase
- 🏗️ Monolith Analysis - Identify and analyze dependencies within monolithic code structures
- 📊 Multiple Output Formats - Export graphs in CSV, JSON, SVG, PNG, or GraphViz formats
- 🎯 Index Store Integration - Leverage Xcode's index store for accurate dependency tracking
- 🧩 Modular Architecture - Built with clean architecture principles (Domain, Data, Presentation layers)
mint install rofle100lvl/UseGraphClone the repository and build using Swift Package Manager:
git clone https://github.com/rofle100lvl/UseGraph.git
cd UseGraph
swift build -c releaseUseGraph provides two main commands:
Generate a dependency graph for your Swift project:
mint run UseGraph use_graph usage_graph \
--schemes <scheme-name> \
--project-path <path-to-xcodeproj-or-workspace> \
--format <output-format> \
--index-store <path-to-index-store>Parameters:
--schemes(required) - Comma-separated list of schemes to analyze--project-path(optional) - Path to your.xcodeprojor.xcworkspacefile--format(optional) - Output format:csv,json,svg,png, orgv(default:csv)--index-store(optional) - Path to Xcode's index store data folder
(typically:~/Library/Developer/Xcode/DerivedData/<your-project>/Index.noindex/DataStore/)
Example:
mint run UseGraph use_graph usage_graph \
--schemes MyApp \
--project-path ./MyApp.xcodeproj \
--format svg \
--index-store ~/Library/Developer/Xcode/DerivedData/MyApp-xxx/Index.noindex/DataStore/Analyze dependencies within a monolithic module to help break it down:
mint run UseGraph use_graph monolith_destroyer \
--schemes <scheme-name> \
--project-path <path-to-xcodeproj-or-workspace> \
--monolith-path <path-to-monolith-directory> \
--index-store <path-to-index-store>Parameters:
--schemes(required) - Comma-separated list of schemes to analyze--project-path(optional) - Path to your.xcodeprojor.xcworkspacefile--monolith-path(required) - Path to the monolithic module directory you want to analyze--index-store(optional) - Path to Xcode's index store data folder
Example:
mint run UseGraph use_graph monolith_destroyer \
--schemes MyApp \
--project-path ./MyApp.xcodeproj \
--monolith-path ./Sources/CoreModule \
--index-store ~/Library/Developer/Xcode/DerivedData/MyApp-xxx/Index.noindex/DataStore/UseGraph supports multiple output formats for different use cases:
- CSV - Tabular format for spreadsheet analysis
- JSON - Structured data for programmatic processing
- SVG - Scalable vector graphics for web viewing
- PNG - Raster image format for documentation
- GV - GraphViz DOT format for custom rendering
UseGraph is built with a clean, modular architecture:
- UseGraphCore - Core graph building and output formatting logic
- UseGraphPeriphery - Integration with Periphery for advanced code analysis
- UseGraphStaticAnalysis - Static analysis using SwiftSyntax
- UseGraphFrontend - Command-line interface and argument parsing
- Utils - Shared utilities and helpers
- macOS 14.0+
- Swift 5.9+
- Xcode 15.0+ (for index store generation)
- swift-argument-parser - Command-line argument parsing
- periphery - Swift code analysis
- swift-syntax - Swift syntax parsing
- GraphViz - Graph visualization
- XcodeProj - Xcode project file parsing
- swift-indexstore - Index store reading
Contributions are welcome! Please feel free to submit a Pull Request.
