Do not sort references in xcworkspace

Context

My Workspace.swift manifest looks like this:

let workspace = Workspace(
    name: "MY_Project",
    projects: [
        /// iOS App Project
        "iOS",
        /// iOS Feature-Projects 
        "iOS/Features/**",

        /// tvOS App Project
        "tvOS",
        /// tOS App Project
        "tvOS/Features/**",

        /// Shared Frameworks
        "Frameworks/**"
    ]
)

Problem

When generating a project, the order of declared projects is different:

Proposal

It seems there is no practical benefit from that all references are sorted alphabetically.
Why not display them in the order they are defined in Workspace.swift (except for glob patterns)


It might also be a good idea to create a separate Group for projects that are in subdirectories of other project. In my case, feature module projects are in subdirectory of the iOS/ folder, which is also a separate project in itself.

1 Like

I don’t have any strong opinions on this. I lean on keeping the default as it is, since some developers might have got used to it, and introduce a generation option so that you can change the default based on your preferences. Maybe something like:

generationOptions: .options(projectsOrder: .manifestOrder)

I’ve been searching for something like this for the past hour and finally landed on this thread. I would love to see the ordering in the manifest preserved. Foy my use case it makes sense to group certain modules together to illustrate the dependency layering of my project and to move the main executable to the top of the groups instead of being buried between a bunch of groups.

I started to dig in to the Tist source code to see roughly what was going on and found myself in in WorkspaceStructureGenerator.swift and playing with the buildGraph(path: AbsolutePath) -> Graph method, but I’m unsure if this is the right place. I only spent a few minutes looking around before having to rush off, but I’d be happy to look further if someone has some guidance on where something like this should be implemented. Maybe @pepicrft you might have some thoughts on this?

1 Like

@marekfort maybe you might have some ideas about this also?

:wave: It seems that the sorting is happening here. Note that there are file and project nodes, and I believe that’s the reason why we decided to go the path of sorting things alphabetically. If we wanted to show the projects as they are listed in the manifest file, where would you place the files? Right after in the order in which they are defined?

1 Like

This is where I had a play the other day and just outright removed the sort and it gave an odd order which didn’t seem to follow any logical pattern. I also noticed that all of the dependencies were included in the project nodes which would probably need to be handled too.

But to answer your question; yes I think that would be the desirable outcome. I would like to treat the manifest project ordering as the priority, so anything which isn’t included in that should come afterwards. Now there could be other implications to this that I’m unaware of, so it would be great to hear those if anything comes to mind.