diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 66bbe2ad..8f456b75 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 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` . + **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..08f82dc1 100644 --- a/Sources/ProjectSpec/Dependency.swift +++ b/Sources/ProjectSpec/Dependency.swift @@ -17,12 +17,14 @@ public struct Dependency: Equatable { public var codeSign: Bool = true public var removeHeaders: Bool = true public var link: Bool = true + public var implicit: Bool = false - 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 = false) { self.type = type self.reference = reference self.embed = embed self.link = link + self.implicit = implicit } public enum DependencyType { @@ -69,7 +71,7 @@ extension Dependency: JSONObjectConvertible { } embed = jsonDictionary.json(atKeyPath: "embed") - + if let bool: Bool = jsonDictionary.json(atKeyPath: "link") { link = bool } @@ -79,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 915758c4..69b24b98 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 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) + } let buildFile = PBXBuildFile(reference: referenceGenerator.generate(PBXBuildFile.self, fileReference + target.name), fileRef: fileReference) addObject(buildFile)