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

Set error message for missing build targets in scheme #1040

Merged
merged 2 commits into from
Mar 31, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#### Fixed
- Fixed regression on **.storekit** configuration files' default build phase. [#1026](https://github.com/yonaskolb/XcodeGen/pull/1026) @jcolicchio
- Fixed bug where schemes without a build target would crash instead of displaying an error [#1040](https://github.com/yonaskolb/XcodeGen/pull/1040) @dalemyers

#### Internal
- Build universal binaries for release. XcodeGen now runs natively on Apple Silicon. [#1024](https://github.com/yonaskolb/XcodeGen/pull/1024) @thii
Expand Down
8 changes: 7 additions & 1 deletion Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ public class SchemeGenerator {
if let targetName = scheme.run?.executable {
schemeTarget = project.getTarget(targetName)
} else {
let name = scheme.build.targets.first { $0.buildTypes.contains(.running) }?.target.name ?? scheme.build.targets.first!.target.name
guard let firstTarget = scheme.build.targets.first else {
throw SchemeGenerationError.missingBuildTargets(scheme.name)
}
let name = scheme.build.targets.first { $0.buildTypes.contains(.running) }?.target.name ?? firstTarget.target.name
schemeTarget = target ?? project.getTarget(name)
}

Expand Down Expand Up @@ -350,13 +353,16 @@ enum SchemeGenerationError: Error, CustomStringConvertible {

case missingTarget(TargetReference, projectPath: String)
case missingProject(String)
case missingBuildTargets(String)

var description: String {
switch self {
case .missingTarget(let target, let projectPath):
return "Unable to find target named \"\(target)\" in \"\(projectPath)\""
case .missingProject(let project):
return "Unable to find project reference named \"\(project)\" in project.yml"
case .missingBuildTargets(let name):
return "Unable to find at least one build target in scheme \"\(name)\""
}
}
}
Expand Down