Make sure to create parent group structure for local packages (#1417)

* Make sure to create parent group structure for local packages

* Remove redundant localPackageGroup variable

---------

Co-authored-by: Jaap Manenschijn <jaap.maneschijn@rabobank.nl>
This commit is contained in:
Jaap Manenschijn
2024-02-14 20:18:16 +11:00
committed by GitHub
co-authored by Jaap Manenschijn
parent 19109ac8c1
commit 54139090a3
4 changed files with 23 additions and 20 deletions
+7 -18
View File
@@ -18,7 +18,6 @@ class SourceGenerator {
private var fileReferencesByPath: [String: PBXFileElement] = [:]
private var groupsByPath: [Path: PBXGroup] = [:]
private var variantGroupsByPath: [Path: PBXVariantGroup] = [:]
private var localPackageGroup: PBXGroup?
private let project: Project
let pbxProj: PBXProj
@@ -54,19 +53,11 @@ class SourceGenerator {
}
func createLocalPackage(path: Path, group: Path?) throws {
var pbxGroup: PBXGroup?
if let location = group {
let fullLocationPath = project.basePath + location
pbxGroup = getGroup(path: fullLocationPath, mergingChildren: [], createIntermediateGroups: true, hasCustomParent: false, isBaseGroup: true)
var parentGroup: String = project.options.localPackagesGroup ?? "Packages"
if let group {
parentGroup = group.string
}
if localPackageGroup == nil && group == nil {
let groupName = project.options.localPackagesGroup ?? "Packages"
localPackageGroup = addObject(PBXGroup(sourceTree: .sourceRoot, name: groupName))
rootGroups.insert(localPackageGroup!)
}
let absolutePath = project.basePath + path.normalize()
// Get the local package's relative path from the project root
@@ -80,11 +71,9 @@ class SourceGenerator {
path: fileReferencePath
)
)
if let pbxGroup = pbxGroup {
pbxGroup.children.append(fileReference)
} else {
localPackageGroup!.children.append(fileReference)
}
let parentGroups = parentGroup.components(separatedBy: "/")
createParentGroups(parentGroups, for: fileReference)
}
/// Collects an array complete of all `SourceFile` objects that make up the target based on the provided `TargetSource` definitions.