A modern macOS tool for analyzing and organizing your Swift codebase.
This app is still very much in progress. No point in reporting bugs just yet; I’m still working on the basic functionality.
Treeswift helps Swift developers understand their code structure, eliminate unused code, and improve encapsulation in iOS, macOS, and server-side Swift projects through an intuitive native macOS interface.
- macOS 15.6 "Sequoia" or higher
- Xcode (for building and for analyzing Xcode projects)
This is an early preview release. Feedback and contributions are welcome via GitHub Issues.
- Native macOS Interface
- Multiple Configurations - Save and manage multiple project configurations with persistent settings
- Automatic Scheme Detection - Detects available schemes from Xcode projects automatically
- Multiple Result Views - Four complementary views of your codebase:
- Unused Code Analysis: Identify unused declarations and dead code
- Tree Tab: Hierarchical view organized by subview structure
- View Extensions Tab: SwiftUI View extensions categorized and organized
- Shared Tab: Shared code elements and utilities
- Context-Sensitive Details - Right panel shows detailed information about selected items and controls to fix code warnings
- Drag-and-Drop Support - Drop project files onto the sidebar to create configurations
Treeswift uses a three-column layout:
- List of saved project configurations (Xcode projects and Swift Packages)
- Drag-and-drop support for adding new projects
- Add (+) and Delete (−) buttons for configuration management
Configuration Section:
- Scheme selector for Xcode projects (automatically detected)
- Build arguments and scanning options
- Layout and display preferences
Results Section:
- Four tabs showing different views of scan results
- Progress indicator during scanning
- Error reporting for failed scans
Shows context-aware information based on the selected tab:
- Unused Code Tab: File/folder information, Xcode integration buttons, analysis warnings, buttons to fix or hide warnings
- Other Tabs: Declaration details, type information, conformances, relationships, size indicators, and referencers
Clone the repository and build using Xcode.
git clone https://github.com/danwood/treeswift.git-
Create a Configuration
- Drag an Xcode project (.xcodeproj) or workspace (.xcworkspace) or folder containing a Package.swift file onto the sidebar, or
- Click the + button and select your project file
-
Select Schemes
- For Xcode projects, click the schemes button to select which schemes to analyze
- Schemes are automatically detected from your project
-
Configure Options (optional)
- Add build arguments if needed
- Adjust scanning options in the collapsible sections
-
Run Scan
- Click the "Build & Scan" button in the toolbar
- Watch the progress indicator as the scan runs
-
Explore the Results!
Treeswift supports command-line operation for automation and testing:
# List all saved configurations
Treeswift --list
# Run a scan for a specific configuration
Treeswift --scan "MyProject"
# Launch the GUI (default behavior)
TreeswiftThe CLI is useful for:
- Testing scan functionality without GUI interaction
- CI/CD integration
- Automated testing workflows
- Debugging scan output
Treeswift includes an embedded HTTP server for external control — useful for scripting, CI pipelines, and AI-assisted workflows. Launch with --automation-port <port> to enable it:
open /path/to/Treeswift.app --args --automation-port 21663When ready, the server writes the active port to /tmp/treeswift-control.port. All endpoints are on http://localhost:<port>/ and return JSON.
Key endpoints:
GET /status— server state (idleorscanning)GET /configurations— list all saved configurationsPOST /configurations— create a new configurationPOST /configurations/:id/scan— start a scanGET /configurations/:id/scan/wait— long-poll until scan completesGET /configurations/:id/results/summary— warning counts by typeGET /configurations/:id/results/periphery-tree— full results hierarchyPOST /configurations/:id/removal/preview— preview code removal (dry run)POST /configurations/:id/removal/execute— execute code removalPOST /quit— terminate the application
See docs/automation-api.md for the complete API reference with curl examples.
Treeswift integrates the Periphery static analysis engine as one component of its analysis capabilities. The app includes a recent version of Periphery as a git subtree, with modifications to enable deeper integration and enhanced analysis features.
Contributions are welcome! Please open an issue to discuss proposed changes or submit a pull request.
Treeswift incorporates components from Periphery by Ian Leitch and contributors.