Commit c68ce09a authored by Fabio Pelosin's avatar Fabio Pelosin

[AggregateTarget] Add #user_targets

parent ba68b811
...@@ -124,18 +124,7 @@ module Pod ...@@ -124,18 +124,7 @@ module Pod
# match the given target. # match the given target.
# #
def native_targets def native_targets
unless @native_targets @native_targets ||= target.user_targets(user_project)
target_uuids = target.user_target_uuids
@native_targets = target_uuids.map do |uuid|
native_target = user_project.objects_by_uuid[uuid]
unless native_target
raise Informative, "[Bug] Unable to find the target with " \
"the `#{uuid}` UUID for the `#{target}` integration library"
end
native_target
end
end
@native_targets
end end
# @return [Array<PBXNativeTarget>] The list of the targets # @return [Array<PBXNativeTarget>] The list of the targets
......
...@@ -38,13 +38,28 @@ module Pod ...@@ -38,13 +38,28 @@ module Pod
attr_accessor :user_project_path attr_accessor :user_project_path
# @return [String] the list of the UUIDs of the user targets that will be # @return [String] the list of the UUIDs of the user targets that will be
# integrated by this target as identified by the analizer. # integrated by this target as identified by the analyzer.
# #
# @note The target instances are not stored to prevent editing different # @note The target instances are not stored to prevent editing different
# instances. # instances.
# #
attr_accessor :user_target_uuids attr_accessor :user_target_uuids
# @return [Array<PBXNativeTarget>] The list of all the user targets that
# will be integrated by this target.
#
def user_targets(project = nil)
project ||= Xcodeproj::Project.open(user_project_path)
user_target_uuids.map do |uuid|
native_target = project.objects_by_uuid[uuid]
unless native_target
raise Informative, "[Bug] Unable to find the target with " \
"the `#{uuid}` UUID for the `#{self}` integration library"
end
native_target
end
end
# @return [Hash<String, Xcodeproj::Config>] Map from configuration name to # @return [Hash<String, Xcodeproj::Config>] Map from configuration name to
# configuration file for the target # configuration file for the target
# #
......
...@@ -101,7 +101,7 @@ module Pod ...@@ -101,7 +101,7 @@ module Pod
it 'returns the targets that need to be integrated' do it 'returns the targets that need to be integrated' do
pods_library = @project.frameworks_group.new_product_ref_for_target('Pods', :static_library) pods_library = @project.frameworks_group.new_product_ref_for_target('Pods', :static_library)
@target.frameworks_build_phase.add_file_reference(pods_library) @target.frameworks_build_phase.add_file_reference(pods_library)
@target_integrator.stubs(:user_project).returns(@project) @project.save
@target_integrator.send(:native_targets_to_integrate).map(&:name).should.be.empty @target_integrator.send(:native_targets_to_integrate).map(&:name).should.be.empty
end end
......
...@@ -24,6 +24,15 @@ module Pod ...@@ -24,6 +24,15 @@ module Pod
it "returns the name of its product" do it "returns the name of its product" do
@target.product_name.should == 'libPods.a' @target.product_name.should == 'libPods.a'
end end
it 'returns the user targets' do
project_path = SpecHelper.fixture('SampleProject/SampleProject.xcodeproj')
@target.user_project_path = project_path
@target.user_target_uuids = ['A346496C14F9BE9A0080D870']
targets = @target.user_targets
targets.count.should == 1
targets.first.class.should == Xcodeproj::Project::PBXNativeTarget
end
end end
describe "Support files" do describe "Support files" do
......
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