Skip to content

Commit

Permalink
List all targets when suggesting the use of --target flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaan Dedeoglu committed Nov 15, 2019
1 parent 6ff2102 commit 3302237
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/Shark/XcodeProjectHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ struct XcodeProjectHelper {

func resourcePaths() throws -> ResourcePaths {
let eligibleTargets = xcodeproj.pbxproj.nativeTargets.filter({ $0.productType == .application || $0.productType == .framework })
let eligibleTargetsHelpString = "The available targets are:\n\(eligibleTargets.map({ "- \($0.name)" }).joined(separator: "\n"))"
let selectedTarget: PBXNativeTarget

if let targetName = targetName {
guard let target = eligibleTargets.first(where: { $0.name == targetName }) else {
print("No target found with name \(targetName). The available targets are:\n\(eligibleTargets.map({ "- \($0.name)" }).joined(separator: "\n"))")
print("No target found with name \(targetName).\n\(eligibleTargetsHelpString)")
exit(EXIT_FAILURE)
}

selectedTarget = target
} else {
guard eligibleTargets.count == 1 else {
print("Multiple application targets found, please specify the target by using the --target flag")
print("Multiple application targets found, please specify the target by using the --target flag.\n\(eligibleTargetsHelpString)")
exit(EXIT_FAILURE)
}

Expand Down

0 comments on commit 3302237

Please sign in to comment.