Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implicit option to framework Dependency #166

Merged
merged 4 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions Sources/ProjectSpec/Dependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -69,7 +71,7 @@ extension Dependency: JSONObjectConvertible {
}

embed = jsonDictionary.json(atKeyPath: "embed")

if let bool: Bool = jsonDictionary.json(atKeyPath: "link") {
link = bool
}
Expand All @@ -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
}
}
}
8 changes: 6 additions & 2 deletions Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down