[xcodegen] Avoid buildable folders for mixed Swift targets

If a Swift target has sources in its folder that
aren't part of the target, we can't form a buildable
folder.
This commit is contained in:
Hamish Knight
2024-12-14 19:53:51 +00:00
parent 54bf65b2e9
commit 486cd42bba
2 changed files with 17 additions and 4 deletions

View File

@@ -531,11 +531,20 @@ fileprivate final class ProjectGenerator {
guard checkNotExcluded(buildRule.parentPath, for: "Swift target") else {
return nil
}
// Create the target. Swift targets can always use buildable folders
// since they have a consistent set of arguments.
// Swift targets can almost always use buildable folders since they have
// a consistent set of arguments, but we need to ensure we don't have any
// child source files that aren't part of the target.
let canUseBuildableFolder = try {
guard let parent = buildRule.parentPath else { return false }
let repoSources = Set(buildRule.sources.repoSources)
return try getAllRepoSubpaths(of: parent)
.allSatisfy { !$0.isSourceLike || repoSources.contains($0) }
}()
// Create the target.
let target = generateBaseTarget(
targetInfo.name, at: buildRule.parentPath, canUseBuildableFolder: true,
productType: .staticArchive, includeInAllTarget: includeInAllTarget
targetInfo.name, at: buildRule.parentPath,
canUseBuildableFolder: canUseBuildableFolder, productType: .staticArchive,
includeInAllTarget: includeInAllTarget
)
guard let target else { return nil }