@@ -213,10 +213,18 @@ fileprivate final class ProjectGenerator {
213
213
_ name: String , at parentPath: RelativePath ? , canUseBuildableFolder: Bool ,
214
214
productType: Xcode . Target . ProductType ? , includeInAllTarget: Bool
215
215
) -> Xcode . Target ? {
216
- guard targets [ name] == nil else {
217
- log. warning ( " Duplicate target ' \( name) ', skipping " )
218
- return nil
219
- }
216
+ let name = {
217
+ // If we have a same-named target, disambiguate.
218
+ if targets [ name] == nil {
219
+ return name
220
+ }
221
+ var i = 2
222
+ var newName : String { " \( name) \( i) " }
223
+ while targets [ newName] != nil {
224
+ i += 1
225
+ }
226
+ return newName
227
+ } ( )
220
228
var buildableFolder : Xcode . FileReference ?
221
229
if let parentPath, !parentPath. components. isEmpty {
222
230
// If we've been asked to use buildable folders, see if we can create
@@ -747,12 +755,7 @@ fileprivate final class ProjectGenerator {
747
755
let target = try buildDir. getClangTarget (
748
756
for: targetSource, knownUnbuildables: spec. knownUnbuildables
749
757
)
750
- guard var target else { continue }
751
- // We may have a Swift target with the same name, disambiguate.
752
- // FIXME: We ought to be able to support mixed-source targets.
753
- if targets [ target. name] != nil {
754
- target. name = " \( target. name) -clang "
755
- }
758
+ guard let target else { continue }
756
759
try generateClangTarget ( target)
757
760
}
758
761
0 commit comments