r/iOSProgramming • u/PreetyGeek • 18d ago
Discussion Your DerivedData already has a full call graph of your app. I made a tool that reads it.
Every ⌘B writes an index store into DerivedData: every call, read, write and conformance, already resolved by the compiler. Xcode uses it for “Find Call Hierarchy”, but nothing outside Xcode really uses it, and AI agents ignore it completely and grep instead.
SwiftGraph turns that store into a call graph you can query from the terminal:
It works with Xcode projects and SwiftPM packages,
--no-testshides test code, and system frameworks show up as leaves so the tree stays readable. You can set an Xcode scheme in .swiftgraph/config.json, andswiftgraph index --buildwill build and refresh the graph for you.I mainly built it for Claude Code. In a side-by-side test on a 140k-line SwiftUI app, the agent with the graph needed 2 tool calls instead of 8 and about 3.5x fewer input tokens for the same answer. Full numbers and caveats: https://arturgruchala.com/map-not-grep/
Repo (MIT, macOS + Xcode): https://github.com/agruchala/swift-graph
3
u/RiddleGull 16d ago
Bot comments
7
u/dawedev 18d ago
Using the index store instead of grep makes a lot of sense, the compiler already did the hard part. One thing I'd check: I build DevCleaner, a Mac app that clears Xcode caches, and DerivedData is the first folder people wipe, so the store vanishes or goes half stale after a partial build. Does swiftgraph warn when the store is older than the sources, or does it just return a smaller graph? Also with several git worktrees you get one DerivedData folder per path, so picking the right one automatically would save some confusion for agents.
1
u/mikerCZX 17d ago
Love it, will try, thanks
1
u/[deleted] 18d ago
[removed] — view removed comment