We believe that Tuist projects are still the best way to manage your Xcode projects – but we also want any organization out there that works with Xcode to benefit from some of the Tuist features without having to go through the full migration to Tuist project.
Tuist Previews are a first such feature, but can we add support for Xcode projects in some of our existing features? I believe we can.
Xcode projects → XcodeGraph
XcodeGraph is already a piece that’s not specific to Tuist projects – and that’s often the only data input that some of our features like tuist inspect implicit-imports
or tuist graph
need.
During project generation, XcodeGraph
is converted to XcodeProj. Can we go the other direction? Can we read an Xcode project into the XcodeProj
format and then convert it to XcodeGraph
?
If we can, then the inspect implicit-imports
and tuist graph
could be used outside of the context of Tuist projects. And for example, the interactive graphs that @ajkolean has been proposing could be used by the whole iOS community as well!
Conversion implementation
Most of XcodeGraph
models are properties like resources
, sources
, settings
, etc. All of those should be relatively straightforward to migrate from XcodeProj definition. For example, sources
are directly represented by the sourcesBuildPhase.
To load the dependency graph, we can use the Link binary with libraries
build phase. However, a lot of projects suffer from implicit dependencies, so the graph might be incomplete. We’d need to strongly recommend developers to use the inspect implicit-imports
command to ensure other commands like tuist graph
are accurate.
Structuring work
I’d suggest to develop the conversion inside the XcodeGraph repository. We can take some inspiration from xcdiff that uses XcodeProj
to read and compare Xcode projects.
SPM projects
External SPM dependencies would be represented as external dependencies in the XcodeGraph
. The graph knowledge would sort of end at the edges of the SPM graph. But what about projects that use SPM for managing most of their projects? Wouldn’t it be great if they could benefit from features like tuist graph
as well?
To that I say – yes! But the story is a bit more complicated there.
There are two components to this:
- SPM graph itself
- The touchpoints between Xcode graph and SPM graph
SPM graph is different from Xcode graph – we could technically convert it to XcodeGraph to reuse most of our utilities, but it could make things more complex, especially for projects that are purely written in SPM. I believe such work will need deeper exploration and thinking.
I can see having another package called swift-package-manager-graph
that would be for solely representing the SPM graph (or maybe that’s something that’s already in swift-package-manager repository?). For projects that are partly managed by SPM and partly by Xcode, we would either need to convert SPM graphs to XcodeGraph
or we would need to work with two graphs seperately. I think the former might be easier, but again, this needs some deeper thinking and exploration.
Feedback
What do you think about this proposal? Is the support of Xcode projects for some of Tuist features worth the investment and maintenance?
Any blind spots that I have missed?