@@ -259,6 +259,96 @@ class PBXProjGeneratorTests: XCTestCase {
259259 . map { $0. nameOrPath }
260260 try expect ( screenGroups) == [ " mainScreen1.swift " , " mainScreen2.swift " , " View " , " Presenter " , " Interactor " , " Entities " , " Assembly " ]
261261 }
262+
263+ $0. it ( " sorts SPM packages " ) {
264+ var options = SpecOptions ( )
265+ options. groupSortPosition = . top
266+ options. groupOrdering = [
267+ GroupOrdering (
268+ order: [
269+ " Sources " ,
270+ " Resources " ,
271+ " Tests " ,
272+ " Packages " ,
273+ " Support files " ,
274+ " Configurations " ,
275+ ]
276+ ) ,
277+ GroupOrdering (
278+ pattern: " Packages " ,
279+ order: [
280+ " FeatureA " ,
281+ " FeatureB " ,
282+ " Common " ,
283+ ]
284+ ) ,
285+ ]
286+
287+ let directories = """
288+ Configurations:
289+ - file.swift
290+ Resources:
291+ - file.swift
292+ Sources:
293+ - MainScreen:
294+ - mainScreen1.swift
295+ - mainScreen2.swift
296+ - Assembly:
297+ - file.swift
298+ - Entities:
299+ - file.swift
300+ - Interactor:
301+ - file.swift
302+ - Presenter:
303+ - file.swift
304+ - View:
305+ - file.swift
306+ Support files:
307+ - file.swift
308+ Packages:
309+ - Common:
310+ - Package.swift
311+ - FeatureA:
312+ - Package.swift
313+ - FeatureB:
314+ - Package.swift
315+ Tests:
316+ - file.swift
317+ UITests:
318+ - file.swift
319+ """
320+ try createDirectories ( directories)
321+
322+ let target = Target ( name: " Test " , type: . application, platform: . iOS, sources: [ " Configurations " , " Resources " , " Sources " , " Support files " , " Tests " , " UITests " ] )
323+ let project = Project (
324+ basePath: directoryPath,
325+ name: " Test " ,
326+ targets: [ target] ,
327+ packages: [
328+ " Common " : . local( path: " Packages/Common " , group: nil ) ,
329+ " FeatureA " : . local( path: " Packages/FeatureA " , group: nil ) ,
330+ " FeatureB " : . local( path: " Packages/FeatureB " , group: nil ) ,
331+ ] ,
332+ options: options
333+ )
334+ let projGenerator = PBXProjGenerator ( project: project)
335+
336+ let pbxProj = try project. generatePbxProj ( )
337+ let group = try pbxProj. getMainGroup ( )
338+
339+ projGenerator. setupGroupOrdering ( group: group)
340+
341+ let mainGroups = group. children. map { $0. nameOrPath }
342+ try expect ( mainGroups) == [ " Sources " , " Resources " , " Tests " , " Packages " , " Support files " , " Configurations " , " UITests " , " Products " ]
343+
344+ let packages = group. children
345+ . first { $0. nameOrPath == " Packages " }
346+ . flatMap { $0 as? PBXGroup } ?
347+ . children
348+ . map ( \. nameOrPath)
349+
350+ try expect ( packages) == [ " FeatureA " , " FeatureB " , " Common " ]
351+ }
262352 }
263353 }
264354
0 commit comments