diff --git a/CHANGELOG.md b/CHANGELOG.md index b27bf722..b4d63b6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,18 @@ ## Next Version +### Added + +### Fixed + +- Fix external dependencies from being removed by Xcode #1354 @OdNairy + ## 2.35.0 ### Added - Added support for shared breakpoints #177 @alexruperez @myihsan -- Added support for `putResourcesBeforeSourcesBuildPhase` in a target #1351 @mat1th +- Added support for `putResourcesBeforeSourcesBuildPhase` in a target #1351 @mat1th ### Fixed diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 8a3509c5..6e77c3f8 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -423,16 +423,32 @@ public class PBXProjGenerator { path = "lib\(tmpPath)" } - let productReferenceProxy = addObject( - PBXReferenceProxy( - fileType: targetObject.productNameWithExtension().flatMap { Xcode.fileType(path: Path($0)) }, - path: path, - remote: productProxy, - sourceTree: .buildProductsDir - ) - ) + let productReferenceProxyFileType = targetObject.productNameWithExtension() + .flatMap { Xcode.fileType(path: Path($0)) } + + let existingValue = self.pbxProj.referenceProxies.first { referenceProxy in + referenceProxy.path == path && + referenceProxy.remote == productProxy && + referenceProxy.sourceTree == .buildProductsDir && + referenceProxy.fileType == productReferenceProxyFileType + } + + let productReferenceProxy: PBXReferenceProxy + if let existingValue = existingValue { + productReferenceProxy = existingValue + } else { + productReferenceProxy = addObject( + PBXReferenceProxy( + fileType: productReferenceProxyFileType, + path: path, + remote: productProxy, + sourceTree: .buildProductsDir + ) + ) + + productsGroup.children.append(productReferenceProxy) + } - productsGroup.children.append(productReferenceProxy) let targetDependency = addObject( PBXTargetDependency(