mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Validate project reference path
This commit is contained in:
@@ -178,6 +178,12 @@ extension Project {
|
||||
}
|
||||
}
|
||||
|
||||
for projectReference in projectReferences {
|
||||
if !(basePath + projectReference.path).exists {
|
||||
errors.append(.invalidProjectReferencePath(projectReference))
|
||||
}
|
||||
}
|
||||
|
||||
for scheme in schemes {
|
||||
for buildTarget in scheme.build.targets {
|
||||
switch buildTarget.target.location {
|
||||
|
||||
@@ -30,6 +30,7 @@ public struct SpecValidationError: Error, CustomStringConvertible {
|
||||
case missingDefaultConfig(configName: String)
|
||||
case invalidPerConfigSettings
|
||||
case invalidProjectReference(scheme: String, reference: String)
|
||||
case invalidProjectReferencePath(ProjectReference)
|
||||
|
||||
public var description: String {
|
||||
switch self {
|
||||
@@ -75,6 +76,8 @@ public struct SpecValidationError: Error, CustomStringConvertible {
|
||||
return "Settings that are for a specific config must go in \"configs\". \"base\" can be used for common settings"
|
||||
case let .invalidProjectReference(scheme, project):
|
||||
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)\""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,6 +226,13 @@ class ProjectSpecTests: XCTestCase {
|
||||
try expectValidationError(project, .invalidProjectReference(scheme: "scheme1", reference: "invalidProjectRef"))
|
||||
}
|
||||
|
||||
$0.it("fails with invalid project reference path") {
|
||||
var project = baseProject
|
||||
let reference = ProjectReference(name: "InvalidProj", path: "invalid_path")
|
||||
project.projectReferences = [reference]
|
||||
try expectValidationError(project, .invalidProjectReferencePath(reference))
|
||||
}
|
||||
|
||||
$0.it("allows missing optional file") {
|
||||
var project = baseProject
|
||||
project.targets = [Target(
|
||||
|
||||
Reference in New Issue
Block a user