Skip to content

Commit 612d513

Browse files
committed
Sort targets for outputting to xcodeproj.
Motivation: Repeated runs of generate-xcodeproj generate different results as Set is used to store targets which is ordered by hash. Hash is randomly seeded between runs making the set be differently ordered on each run. Having the output reordered on rerun makes comparison very difficult and is particularly annoying if the generated project is to be stored in revision control or similar. Change: Sort the targets before output, removing the major source of differences between runs.
1 parent 90ff0b7 commit 612d513

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/Xcodeproj/SchemesGenerator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public final class SchemesGenerator {
116116
"""
117117

118118
// Create buildable references for non-test targets.
119-
for target in scheme.regularTargets {
119+
for target in scheme.regularTargets.sorted(by: { $0.name < $1.name }) {
120120
stream <<< """
121121
<BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES">
122122
<BuildableReference
@@ -148,7 +148,7 @@ public final class SchemesGenerator {
148148
"""
149149

150150
// Create testable references.
151-
for target in scheme.testTargets {
151+
for target in scheme.testTargets.sorted(by: { $0.name < $1.name }) {
152152
stream <<< """
153153
<TestableReference
154154
skipped = "NO">

Sources/Xcodeproj/pbxproj.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public func xcodeProject(
385385
// Go through all the targets, creating targets and adding file references
386386
// to the group tree (the specific top-level group under which they are
387387
// added depends on whether or not the target is a test target).
388-
for target in targets {
388+
for target in targets.sorted(by: { $0.name < $1.name }) {
389389
// Determine the appropriate product type based on the kind of target.
390390
// FIXME: We should factor this out.
391391
let productType: Xcode.Target.ProductType

0 commit comments

Comments
 (0)