added options.groupSortPosition

This commit is contained in:
Yonas Kolb
2018-07-24 22:59:24 +10:00
parent 91d2177f84
commit f51280485d
6 changed files with 45 additions and 16 deletions
+20 -2
View File
@@ -395,10 +395,13 @@ public class PBXProjGenerator {
return ObjectReference(reference: reference, object: fileElement)
}
.sorted { child1, child2 in
if child1.object.sortOrder == child2.object.sortOrder {
let sortOrder1 = child1.object.getSortOrder(groupSortPosition: project.options.groupSortPosition)
let sortOrder2 = child2.object.getSortOrder(groupSortPosition: project.options.groupSortPosition)
if sortOrder1 == sortOrder2 {
return child1.object.nameOrPath.localizedStandardCompare(child2.object.nameOrPath) == .orderedAscending
} else {
return child1.object.sortOrder < child2.object.sortOrder
return sortOrder1 < sortOrder2
}
}
group.object.children = children.map { $0.reference }.filter { $0 != group.reference }
@@ -875,3 +878,18 @@ extension Target {
return type.isApp || type.isTest
}
}
extension PBXFileElement {
public func getSortOrder(groupSortPosition: SpecOptions.GroupSortPosition) -> Int {
if type(of: self).isa == "PBXGroup" {
switch groupSortPosition {
case .top: return -1
case .bottom: return 1
case .none: return 0
}
} else {
return 0
}
}
}
@@ -6,14 +6,6 @@ extension PBXFileElement {
public var nameOrPath: String {
return name ?? path ?? ""
}
public var sortOrder: Int {
if type(of: self).isa == "PBXGroup" {
return 1
} else {
return 0
}
}
}
extension PBXProj {