Skip to content

Commit

Permalink
Merge pull request #2050 from tuist/chimera-carthage-platform-support
Browse files Browse the repository at this point in the history
Adding platform support for Dependency.swift
  • Loading branch information
Pedro Piñera Buendía committed Nov 19, 2020
2 parents 1ebf811 + cbb0ff8 commit 56ecc99
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
17 changes: 14 additions & 3 deletions Sources/ProjectDescription/Dependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,29 @@ public struct Dependency: Codable, Equatable {
/// Dependecy manager used to retrieve the dependecy
public let manager: Dependency.Manager

public init(name: String, requirement: Dependency.Requirement, manager: Dependency.Manager) {
/// Set of platforms for the given dependency
public let platforms: Set<Platform>

public init(name: String,
requirement: Dependency.Requirement,
manager: Dependency.Manager,
platforms: [Platform])
{
self.name = name
self.requirement = requirement
self.manager = manager
self.platforms = Set(platforms)
}

/// Carthage dependency initailizer
/// - Parameter name: Name of the dependency
/// - Parameter requirement: Type of requirement for the given dependency
/// - Returns Dependency
public static func carthage(name: String, requirement: Dependency.Requirement) -> Dependency {
Dependency(name: name, requirement: requirement, manager: .carthage)
public static func carthage(name: String,
requirement: Dependency.Requirement,
platforms: [Platform]) -> Dependency
{
Dependency(name: name, requirement: requirement, manager: .carthage, platforms: platforms)
}

public static func == (lhs: Dependency, rhs: Dependency) -> Bool {
Expand Down
3 changes: 3 additions & 0 deletions Sources/TuistCore/Models/CarthageDependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ struct CarthageDependency {

/// Type of requirement for the given dependency
let requirement: Requirement

/// Set of platforms for the given dependency
let platforms: Set<Platform>
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,6 @@ extension Dependencies {
public static func test(name: String = "Any Dependency",
requirement: Dependency.Requirement = .exact("1.4.0")) -> Dependencies
{
Dependencies([.carthage(name: name, requirement: requirement)])
Dependencies([.carthage(name: name, requirement: requirement, platforms: [.iOS])])
}
}
2 changes: 1 addition & 1 deletion fixtures/ios_app_with_helpers/Tuist/Dependencies.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ProjectDescription

let dependencies = Dependencies([
.carthage(name: "Alamofire", requirement: .exact("5.3.0")),
.carthage(name: "Alamofire", requirement: .exact("5.3.0"), platforms: [.iOS]),
])

0 comments on commit 56ecc99

Please sign in to comment.