From 5eb9468e97e9002283278727c99ebbc07c91f2a3 Mon Sep 17 00:00:00 2001 From: Cameron Mc Gorian Date: Tue, 21 Nov 2017 07:47:57 +0100 Subject: [PATCH 1/4] Add implicit type to Dependency --- Docs/ProjectSpec.md | 6 ++++++ Sources/ProjectSpec/Dependency.swift | 4 +++- Sources/XcodeGenKit/PBXProjGenerator.swift | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 66bbe2ad..e70d7c88 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -247,6 +247,12 @@ These only applied to `target` and `framework` dependencies. - ⚪️ **codeSign**: `Bool` - Whether the `codeSignOnCopy` setting is applied when embedding framework. Defaults to true - ⚪️ **removeHeaders**: `Bool` - Whether the `removeHeadersOnCopy` setting is applied when embedding the framework. Defaults to true +**Implicit Framework options**: + +This only applies to `framework` dependencies. + +- ⚪️ **implicit**: `Bool` - Whether the framework is an implicit dependency. This can be useful in a Workspace where projects are not nested within each other. + **Carthage Dependency** Carthage frameworks are expected to be in `CARTHAGE_BUILD_PATH/PLATFORM/FRAMEWORK.framework` where: diff --git a/Sources/ProjectSpec/Dependency.swift b/Sources/ProjectSpec/Dependency.swift index f56a676e..d4cf6873 100644 --- a/Sources/ProjectSpec/Dependency.swift +++ b/Sources/ProjectSpec/Dependency.swift @@ -17,8 +17,9 @@ public struct Dependency: Equatable { public var codeSign: Bool = true public var removeHeaders: Bool = true public var link: Bool = true + public var implicit: Bool? - public init(type: DependencyType, reference: String, embed: Bool? = nil, link: Bool = true) { + public init(type: DependencyType, reference: String, embed: Bool? = nil, link: Bool = true, implicit: Bool? = nil) { self.type = type self.reference = reference self.embed = embed @@ -69,6 +70,7 @@ extension Dependency: JSONObjectConvertible { } embed = jsonDictionary.json(atKeyPath: "embed") + implicit = jsonDictionary.json(atKeyPath: "implicit") if let bool: Bool = jsonDictionary.json(atKeyPath: "link") { link = bool diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 915758c4..f11de371 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -276,8 +276,12 @@ public class PBXProjGenerator { } case .framework: - - let fileReference = sourceGenerator.getFileReference(path: Path(dependency.reference), inPath: spec.basePath) + let fileReference: String + if let implicit = dependency.implicit, implicit == true { + fileReference = sourceGenerator.getFileReference(path: Path(dependency.reference), inPath: spec.basePath, sourceTree: .buildProductsDir) + } else { + fileReference = sourceGenerator.getFileReference(path: Path(dependency.reference), inPath: spec.basePath) + } let buildFile = PBXBuildFile(reference: referenceGenerator.generate(PBXBuildFile.self, fileReference + target.name), fileRef: fileReference) addObject(buildFile) From 99f8bafccf4916b3261b92eaf0e47c38d7154252 Mon Sep 17 00:00:00 2001 From: Cameron Mc Gorian Date: Tue, 21 Nov 2017 11:14:58 +0100 Subject: [PATCH 2/4] Update init method --- Sources/ProjectSpec/Dependency.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/ProjectSpec/Dependency.swift b/Sources/ProjectSpec/Dependency.swift index d4cf6873..8bc70616 100644 --- a/Sources/ProjectSpec/Dependency.swift +++ b/Sources/ProjectSpec/Dependency.swift @@ -24,6 +24,7 @@ public struct Dependency: Equatable { self.reference = reference self.embed = embed self.link = link + self.implicit = implicit } public enum DependencyType { From f143b907f89576eac6b190cd1bde280b6da8e4eb Mon Sep 17 00:00:00 2001 From: Cameron Mc Gorian Date: Tue, 21 Nov 2017 13:51:04 +0100 Subject: [PATCH 3/4] Review feedback --- Docs/ProjectSpec.md | 4 ++-- Sources/ProjectSpec/Dependency.swift | 10 ++++++---- Sources/XcodeGenKit/PBXProjGenerator.swift | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index e70d7c88..505a89b3 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -249,9 +249,9 @@ These only applied to `target` and `framework` dependencies. **Implicit Framework options**: -This only applies to `framework` dependencies. +This only applies to `framework` dependencies. Implicit framework dependencies are useful in Xcode Workspaces which have multiple `.xcodeproj` that are not embedded within each other yet have a dependency on a framework built in an adjacent `.xcodeproj`. -- ⚪️ **implicit**: `Bool` - Whether the framework is an implicit dependency. This can be useful in a Workspace where projects are not nested within each other. +- ⚪️ **implicit**: `Bool` - Whether the framework is an implicit dependency. Defaults to `false` . **Carthage Dependency** diff --git a/Sources/ProjectSpec/Dependency.swift b/Sources/ProjectSpec/Dependency.swift index 8bc70616..08f82dc1 100644 --- a/Sources/ProjectSpec/Dependency.swift +++ b/Sources/ProjectSpec/Dependency.swift @@ -17,9 +17,9 @@ public struct Dependency: Equatable { public var codeSign: Bool = true public var removeHeaders: Bool = true public var link: Bool = true - public var implicit: Bool? + public var implicit: Bool = false - public init(type: DependencyType, reference: String, embed: Bool? = nil, link: Bool = true, implicit: Bool? = nil) { + public init(type: DependencyType, reference: String, embed: Bool? = nil, link: Bool = true, implicit: Bool = false) { self.type = type self.reference = reference self.embed = embed @@ -71,8 +71,7 @@ extension Dependency: JSONObjectConvertible { } embed = jsonDictionary.json(atKeyPath: "embed") - implicit = jsonDictionary.json(atKeyPath: "implicit") - + if let bool: Bool = jsonDictionary.json(atKeyPath: "link") { link = bool } @@ -82,5 +81,8 @@ extension Dependency: JSONObjectConvertible { if let bool: Bool = jsonDictionary.json(atKeyPath: "removeHeaders") { removeHeaders = bool } + if let bool: Bool = jsonDictionary.json(atKeyPath: "implicit") { + implicit = bool + } } } diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index f11de371..69b24b98 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -277,7 +277,7 @@ public class PBXProjGenerator { case .framework: let fileReference: String - if let implicit = dependency.implicit, implicit == true { + if dependency.implicit { fileReference = sourceGenerator.getFileReference(path: Path(dependency.reference), inPath: spec.basePath, sourceTree: .buildProductsDir) } else { fileReference = sourceGenerator.getFileReference(path: Path(dependency.reference), inPath: spec.basePath) From 80b5033e03888dcd73aae69d5f47e8732b42b207 Mon Sep 17 00:00:00 2001 From: Cameron Mc Gorian Date: Tue, 21 Nov 2017 13:54:58 +0100 Subject: [PATCH 4/4] Update docs --- Docs/ProjectSpec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 505a89b3..8f456b75 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -249,7 +249,7 @@ These only applied to `target` and `framework` dependencies. **Implicit Framework options**: -This only applies to `framework` dependencies. Implicit framework dependencies are useful in Xcode Workspaces which have multiple `.xcodeproj` that are not embedded within each other yet have a dependency on a framework built in an adjacent `.xcodeproj`. +This only applies to `framework` dependencies. Implicit framework dependencies are useful in Xcode Workspaces which have multiple `.xcodeproj` that are not embedded within each other yet have a dependency on a framework built in an adjacent `.xcodeproj`. By having `Find Implicit Dependencies` checked within your scheme `Build Options` Xcode can link built frameworks in `BUILT_PRODUCTS_DIR`. - ⚪️ **implicit**: `Bool` - Whether the framework is an implicit dependency. Defaults to `false` .