mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-20 00:58:04 +03:00
sort Projects and Frameworks groups at the end
This commit is contained in:
parent
aca6f9d633
commit
2be5aabaff
@ -16,7 +16,7 @@ public class PBXProjGenerator {
|
||||
var targetAggregateObjects: [String: ObjectReference<PBXAggregateTarget>] = [:]
|
||||
var targetBuildFiles: [String: ObjectReference<PBXBuildFile>] = [:]
|
||||
var targetFileReferences: [String: String] = [:]
|
||||
var topLevelGroups: Set<String> = []
|
||||
|
||||
var carthageFrameworksByPlatform: [String: Set<String>] = [:]
|
||||
var frameworkFiles: [String] = []
|
||||
|
||||
@ -80,6 +80,8 @@ public class PBXProjGenerator {
|
||||
)
|
||||
)
|
||||
|
||||
var derivedGroups: [ObjectReference<PBXGroup>] = []
|
||||
|
||||
let mainGroup = createObject(
|
||||
id: "Project",
|
||||
PBXGroup(
|
||||
@ -161,7 +163,7 @@ public class PBXProjGenerator {
|
||||
name: "Products"
|
||||
)
|
||||
)
|
||||
topLevelGroups.insert(productGroup.reference)
|
||||
derivedGroups.append(productGroup)
|
||||
|
||||
if !carthageFrameworksByPlatform.isEmpty {
|
||||
var platforms: [PBXGroup] = []
|
||||
@ -199,15 +201,16 @@ public class PBXProjGenerator {
|
||||
name: "Frameworks"
|
||||
)
|
||||
)
|
||||
topLevelGroups.insert(group.reference)
|
||||
derivedGroups.append(group)
|
||||
}
|
||||
|
||||
for rootGroup in sourceGenerator.rootGroups {
|
||||
topLevelGroups.insert(rootGroup)
|
||||
}
|
||||
|
||||
mainGroup.object.children = Array(topLevelGroups)
|
||||
mainGroup.object.children = Array(sourceGenerator.rootGroups)
|
||||
sortGroups(group: mainGroup)
|
||||
// add derived groups at the end
|
||||
derivedGroups.forEach(sortGroups)
|
||||
mainGroup.object.children += derivedGroups
|
||||
.sorted { $0.object.nameOrPath.localizedStandardCompare($1.object.nameOrPath) == .orderedAscending }
|
||||
.map { $0.reference }
|
||||
|
||||
let projectAttributes: [String: Any] = ["LastUpgradeCheck": project.xcodeVersion]
|
||||
.merged(project.attributes)
|
||||
|
@ -559,10 +559,8 @@
|
||||
G_8340618952527 /* Configs */,
|
||||
G_3234630030493 /* FileGroup */,
|
||||
G_4661500274312 /* Framework */,
|
||||
G_1952740716080 /* Frameworks */,
|
||||
G_8268950006174 /* iMessage */,
|
||||
G_1646573205915 /* iMessage MessagesExtension */,
|
||||
G_8620238527590 /* Products */,
|
||||
G_7189434949822 /* Resources */,
|
||||
G_6651250437419 /* StandaloneFiles */,
|
||||
G_3997550084026 /* StaticLibrary_ObjC */,
|
||||
@ -571,6 +569,8 @@
|
||||
FR_232605427418 /* Mintfile */,
|
||||
FR_257073931060 /* ResourceFolder */,
|
||||
FR_775316160345 /* SomeFile */,
|
||||
G_1952740716080 /* Frameworks */,
|
||||
G_8620238527590 /* Products */,
|
||||
);
|
||||
indentWidth = 2;
|
||||
sourceTree = "<group>";
|
||||
|
@ -459,6 +459,25 @@ class SourceGeneratorTests: XCTestCase {
|
||||
|
||||
try expect(sourcesBuildPhase.files.count) == 1
|
||||
}
|
||||
|
||||
$0.it("derived directories are sorted last") {
|
||||
let directories = """
|
||||
A:
|
||||
- file.swift
|
||||
P:
|
||||
- file.swift
|
||||
S:
|
||||
- file.swift
|
||||
"""
|
||||
try createDirectories(directories)
|
||||
|
||||
let target = Target(name: "Test", type: .application, platform: .iOS, sources: ["A", "P", "S"], dependencies: [Dependency(type: .carthage, reference: "Alamofire")])
|
||||
let project = Project(basePath: directoryPath, name: "Test", targets: [target])
|
||||
|
||||
let pbxProj = try project.generatePbxProj()
|
||||
let groups = try pbxProj.getMainGroup().children.compactMap { pbxProj.objects.getFileElement(reference: $0)?.nameOrPath }
|
||||
try expect(groups) == ["A", "P", "S", "Frameworks", "Products"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user