mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-11 12:56:03 +03:00
Add ability to sort local Packages group
This commit is contained in:
parent
372f20fe5a
commit
5aaae5e1ec
@ -586,21 +586,40 @@ public class PBXProjGenerator {
|
|||||||
|
|
||||||
func sortGroups(group: PBXGroup) {
|
func sortGroups(group: PBXGroup) {
|
||||||
// sort children
|
// sort children
|
||||||
let children = group.children
|
let children: [PBXFileElement]
|
||||||
.sorted { child1, child2 in
|
if group.name == "Packages",
|
||||||
let sortOrder1 = child1.getSortOrder(groupSortPosition: project.options.groupSortPosition)
|
let packagesOrdering = project.options.groupOrdering.first(where: { $0.pattern == "Packages" }) {
|
||||||
let sortOrder2 = child2.getSortOrder(groupSortPosition: project.options.groupSortPosition)
|
|
||||||
|
var sortedPackages = [PBXFileElement]()
|
||||||
|
var unsortedPackages = Array(group.children)
|
||||||
|
for packageName in packagesOrdering.order {
|
||||||
|
guard let matchingPackage = unsortedPackages.first(where: { $0.nameOrPath == packageName }) else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if sortOrder1 != sortOrder2 {
|
sortedPackages.append(matchingPackage)
|
||||||
return sortOrder1 < sortOrder2
|
unsortedPackages.removeAll { $0 == matchingPackage }
|
||||||
} else {
|
}
|
||||||
if (child1.name, child1.path) != (child2.name, child2.path) {
|
|
||||||
return PBXFileElement.sortByNamePath(child1, child2)
|
children = sortedPackages + unsortedPackages
|
||||||
|
} else {
|
||||||
|
children = group.children
|
||||||
|
.sorted { child1, child2 in
|
||||||
|
let sortOrder1 = child1.getSortOrder(groupSortPosition: project.options.groupSortPosition)
|
||||||
|
let sortOrder2 = child2.getSortOrder(groupSortPosition: project.options.groupSortPosition)
|
||||||
|
|
||||||
|
if sortOrder1 != sortOrder2 {
|
||||||
|
return sortOrder1 < sortOrder2
|
||||||
} else {
|
} else {
|
||||||
return child1.context ?? "" < child2.context ?? ""
|
if (child1.name, child1.path) != (child2.name, child2.path) {
|
||||||
|
return PBXFileElement.sortByNamePath(child1, child2)
|
||||||
|
} else {
|
||||||
|
return child1.context ?? "" < child2.context ?? ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group.children = children.filter { $0 != group }
|
group.children = children.filter { $0 != group }
|
||||||
|
|
||||||
// sort sub groups
|
// sort sub groups
|
||||||
|
Loading…
Reference in New Issue
Block a user