Skip to content
Closed
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
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/Dependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct Dependency: Equatable {
public static let `default` = dynamic
}

public enum DependencyType: Equatable {
public enum DependencyType: Equatable, Hashable {
case target
case framework
case carthage(findFrameworks: Bool?, linkType: CarthageLinkType)
Expand Down
8 changes: 8 additions & 0 deletions Sources/ProjectSpec/SpecValidation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ extension Project {
errors += validateSettings(settings)
}

for target in targets {
let dependencyMap = Dictionary(grouping: target.dependencies, by: { "\($0.type.hashValue)-\($0.reference)" })
let duplicates = dependencyMap.filter({ $1.count > 1 })
for duplicate in duplicates {
errors.append(.duplicateDependencies(target: target.name, dependencyReference: duplicate.1[0].reference))
}
}

for target in projectTargets {

for (config, configFile) in target.configFiles {
Expand Down
3 changes: 3 additions & 0 deletions Sources/ProjectSpec/SpecValidationError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public struct SpecValidationError: Error, CustomStringConvertible {
case invalidPerConfigSettings
case invalidProjectReference(scheme: String, reference: String)
case invalidProjectReferencePath(ProjectReference)
case duplicateDependencies(target: String, dependencyReference: String)

public var description: String {
switch self {
Expand Down Expand Up @@ -79,6 +80,8 @@ public struct SpecValidationError: Error, CustomStringConvertible {
return "Scheme \(scheme.quoted) has invalid project reference \(project.quoted)"
case let .invalidProjectReferencePath(reference):
return "Project reference \(reference.name) has a project file path that doesn't exist \"\(reference.path)\""
case let .duplicateDependencies(target, dependencyReference):
return "Target \(target.quoted) has the dependency \(dependencyReference.quoted) multiple times"
}
}
}
Expand Down