Commit 2cd8016b authored by Samuel Giddins's avatar Samuel Giddins

[TargetInspector] List all native targets when user target isn't found

parent 0bb4eeac
require 'active_support/core_ext/array/conversions'
module Pod
class Installer
class Analyzer
......@@ -103,9 +105,11 @@ module Pod
def compute_targets(user_project)
native_targets = user_project.native_targets
target = native_targets.find { |t| t.name == target_definition.name.to_s }
targets = [target].compact
raise Informative, "Unable to find a target named `#{target_definition.name}`" if targets.empty?
targets
unless target
found = native_targets.map { |t| "`#{t.name}`" }.to_sentence
raise Informative, "Unable to find a target named `#{target_definition.name}`, did find #{found}."
end
[target]
end
# @param [Array<PBXNativeTarget] the user's targets of the project of
......
......@@ -77,6 +77,18 @@ module Pod
e.message.should.match /Unable to find a target named `UserTarget`/
end
it 'suggests project native target names if the target cannot be found' do
target_definition = Podfile::TargetDefinition.new('UserTarget', nil)
user_project = Xcodeproj::Project.new('path')
user_project.new_target(:application, 'FirstTarget', :ios)
user_project.new_target(:application, 'SecondTarget', :ios)
user_project.new_target(:application, 'ThirdTarget', :ios)
target_inspector = TargetInspector.new(target_definition, config.installation_root)
e = lambda { target_inspector.send(:compute_targets, user_project) }.should.raise Informative
e.message.should.include 'did find `FirstTarget`, `SecondTarget`, and `ThirdTarget`.'
end
it 'returns the target with the same name of the target definition' do
target_definition = Podfile::TargetDefinition.new('UserTarget', nil)
user_project = Xcodeproj::Project.new('path')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment