Skip to content

Commit 538e06a

Browse files
committed
Merge pull request #190 from bhargavg/test-group-in-products
Move test products to Tests group under Products
2 parents 57c869a + 49185cf commit 538e06a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Sources/Xcodeproj/Module+PBXProj.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ let rootBuildConfigurationListReference = "___RootConfs_"
3232
let rootBuildConfigurationReference = "_______Debug_"
3333
let rootGroupReference = "___RootGroup_"
3434
let productsGroupReference = "____Products_"
35+
let testProductsGroupReference = "TestProducts_"
3536
let sourcesGroupReference = "_____Sources_"
3637
let testsGroupReference = "_______Tests_"
3738
let linkPhaseFileRefPrefix = "_LinkFileRef_"

Sources/Xcodeproj/pbxproj().swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,35 @@ public func pbxproj(package package: Package, modules: [SwiftModule], products _
157157
print(" sourceTree = '<group>';")
158158
print(" };")
159159

160+
////// “Tests” group
161+
print(" \(testsGroupReference) = {")
162+
print(" isa = PBXGroup;")
163+
print(" children = (" + tests.map{ $0.groupReference }.joined(separator: ", ") + ");")
164+
print(" name = Tests;")
165+
print(" sourceTree = '<group>';")
166+
print(" };")
167+
168+
169+
var productReferences: [String] = []
170+
171+
if !tests.isEmpty {
172+
////// “Product/Tests” group
173+
print(" \(testProductsGroupReference) = {")
174+
print(" isa = PBXGroup;")
175+
print(" children = (" + tests.map{ $0.productReference }.joined(separator: ", ") + ");")
176+
print(" name = Tests;")
177+
print(" sourceTree = '<group>';")
178+
print(" };")
179+
180+
productReferences = [testProductsGroupReference]
181+
}
182+
160183
////// “Products” group
184+
productReferences += nontests.map { $0.productReference }
185+
161186
print(" \(productsGroupReference) = {")
162187
print(" isa = PBXGroup;")
163-
print(" children = (" + modules.map{ $0.productReference }.joined(separator: ", ") + ");")
188+
print(" children = (" + productReferences.joined(separator: ", ") + ");")
164189
print(" name = Products;")
165190
print(" sourceTree = '<group>';")
166191
print(" };")

0 commit comments

Comments
 (0)