Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to sort local Packages group #1366

Closed
wants to merge 1 commit into from

Conversation

mthole
Copy link
Contributor

@mthole mthole commented Jun 21, 2023

In my team's project, we primarily use the local SPM packages organized into "layers", with a directional dependency graph. In such a set up, it's super helpful to have the ordering of the layers in the Xcode organizer reflect the logical ordering of the layers. This PR adds that functionality, expanding the groupOrdering configuration to be applied to the local package ordering as well.

Comment on lines +590 to +591
if group.name == "Packages",
let packagesOrdering = project.options.groupOrdering.first(where: { $0.pattern == "Packages" }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit fragile-- other suggestions welcome!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option could be to treat any folder as "group" for the purposes of sorting in setupGroupOrdering with something like this:

    public func setupGroupOrdering(group: PBXGroup) {
        let groupOrdering = project.options.groupOrdering.first { groupOrdering in
            // existing logic ...
        }

        func isGroupOrFolder(_ element: PBXFileElement) -> Bool {
            element is PBXGroup || (element as? PBXFileReference)?.lastKnownFileType == "folder"
        }
        
        if let order = groupOrdering?.order {
            let files = group.children.filter { !isGroupOrFolder($0) }
            var groups = group.children.filter { isGroupOrFolder($0) }
            
            // existing logic ...

@yonaskolb
Copy link
Owner

Closed in favour of #1466

@yonaskolb yonaskolb closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants