From 18fae50c86a66b27c0b9e74a3bb1ef06933f5a0e Mon Sep 17 00:00:00 2001 From: Fumito Nakazawa Date: Mon, 13 Apr 2020 20:44:14 +0900 Subject: [PATCH] Fix to prevent duplicate addition of carthage static frameworks (#829) * Check carthageLinkType is static * Update changelog --- CHANGELOG.md | 1 + Sources/XcodeGenKit/PBXProjGenerator.swift | 4 +++- Tests/XcodeGenKitTests/ProjectGeneratorTests.swift | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d6343e..10495f0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ #### Fixed - Fixed issue when linking and embeding static frameworks: they should be linked and NOT embed. [#820](https://github.com/yonaskolb/XcodeGen/pull/820) @acecilia - Fixed issue when generating projects for paths with a dot in the folder for swift sources. [#826](https://github.com/yonaskolb/XcodeGen/pull/826) @asifmohd +- Fixed duplicate addition of carthage static frameworks. [#829](https://github.com/yonaskolb/XcodeGen/pull/829) @funzin ## 2.15.1 diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 74189c0d..1a818c09 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -787,7 +787,9 @@ public class PBXProjGenerator { self.carthageFrameworksByPlatform[target.platform.carthageName, default: []].insert(fileReference) - if dependency.link ?? (target.type != .staticLibrary) { + let isStaticLibrary = target.type == .staticLibrary + let isCarthageStaticLink = dependency.carthageLinkType == .static + if dependency.link ?? (!isStaticLibrary && !isCarthageStaticLink) { let buildFile = self.addObject( PBXBuildFile(file: fileReference, settings: getDependencyFrameworkSettings(dependency: dependency)) ) diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 1e40f2dd..a9e2b014 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1124,6 +1124,7 @@ class ProjectGeneratorTests: XCTestCase { guard let files = frameworkBuildPhase?.files, let file = files.first else { return XCTFail("frameworkBuildPhase should have files") } + try expect(files.count) == 1 try expect(file.file?.nameOrPath) == "MyStaticFramework.framework" try expect(target.carthageCopyFrameworkBuildPhase).beNil() @@ -1151,6 +1152,8 @@ class ProjectGeneratorTests: XCTestCase { guard let files = frameworkBuildPhase?.files else { return XCTFail("frameworkBuildPhase should have files") } + try expect(files.count) == 2 + guard let dynamicFramework = files.first(where: { $0.file?.nameOrPath == "MyDynamicFramework.framework" }) else { return XCTFail("Framework Build Phase should have Dynamic Framework") } @@ -1262,6 +1265,7 @@ class ProjectGeneratorTests: XCTestCase { guard let files = frameworkBuildPhase?.files, let file = files.first else { return XCTFail("frameworkBuildPhase should have files") } + try expect(files.count) == 1 try expect(file.file?.nameOrPath) == "MyStaticFramework.framework" try expect(target.carthageCopyFrameworkBuildPhase).beNil() @@ -1289,6 +1293,8 @@ class ProjectGeneratorTests: XCTestCase { guard let files = frameworkBuildPhase?.files else { return XCTFail("frameworkBuildPhase should have files") } + try expect(files.count) == 2 + guard let dynamicFramework = files.first(where: { $0.file?.nameOrPath == "MyDynamicFramework.framework" }) else { return XCTFail("Framework Build Phase should have Dynamic Framework") }