Skip to content

Commit 45e33ae

Browse files
tonyarnoldaciidgh
authored andcommitted
Ensure that targets in the generated Xcode project are output in a sorted order
1 parent e8bc5da commit 45e33ae

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Sources/Xcodeproj/XcodeProjectModelSerialization.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ extension Xcode.Project: PropertyListSerializable {
6464
dict["productRefGroup"] = .identifier(serializer.id(of: productGroup))
6565
}
6666
dict["projectDirPath"] = .string(projectDir)
67-
dict["targets"] = .array(targets.map({ target in
67+
// Ensure that targets are output in a sorted order.
68+
let sortedTargets = targets.sorted(by: { $0.name < $1.name })
69+
dict["targets"] = .array(sortedTargets.map({ target in
6870
.identifier(serializer.serialize(object: target))
6971
}))
7072
return dict

Tests/XcodeprojTests/GenerateXcodeprojTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class GenerateXcodeprojTests: XCTestCase {
4141
XCTAssertEqual(output, """
4242
Information about project "DummyProjectName":
4343
Targets:
44-
FooPackageDescription
4544
DummyModuleName
4645
Foo
47-
46+
FooPackageDescription
47+
4848
Build Configurations:
4949
Debug
5050
Release

0 commit comments

Comments
 (0)