Re-revert 'Throw error instead of fatalError' partially

This commit is contained in:
Yuta Saito 2019-10-24 08:21:32 +09:00
parent 89e5c5636c
commit 848dfe28ba

View File

@ -89,7 +89,7 @@ public class SchemeGenerator {
switch buildTarget.target.location {
case .project(let project):
guard let projectReference = self.project.getProjectReference(project) else {
fatalError("Unable to find project reference named \"\(project)\" in project.yml")
throw SchemeGenerationError.missingProject(project)
}
pbxProj = try XcodeProj(pathString: projectReference.path).pbxproj
projectFilePath = projectReference.path
@ -99,7 +99,7 @@ public class SchemeGenerator {
}
guard let pbxTarget = pbxProj.targets(named: buildTarget.target.name).first else {
fatalError("Unable to find target named \"\(buildTarget.target)\" in \"PBXProj.targets\"")
throw SchemeGenerationError.missingTarget(buildTarget, projectPath: projectFilePath)
}
let buildableName: String
@ -241,6 +241,21 @@ public class SchemeGenerator {
}
}
enum SchemeGenerationError: Error, CustomStringConvertible {
case missingTarget(Scheme.BuildTarget, projectPath: String)
case missingProject(String)
var description: String {
switch self {
case .missingTarget(let buildTarget, let projectPath):
return "Unable to find target named \"\(buildTarget.target)\" in \"\(projectPath)\""
case .missingProject(let project):
return "Unable to find project reference named \"\(project)\" in project.yml"
}
}
}
extension Scheme {
public init(name: String, target: Target, targetScheme: TargetScheme, debugConfig: String, releaseConfig: String) {
self.init(