Commit 69ed45ab authored by Ben Asher's avatar Ben Asher

Collection host product type information during analysis

parent 0fec0e09
...@@ -257,7 +257,8 @@ module Pod ...@@ -257,7 +257,8 @@ module Pod
end end
# Raises an error if there are embedded targets in the Podfile, but # Raises an error if there are embedded targets in the Podfile, but
# their host targets have not been declared in the Podfile # their host targets have not been declared in the Podfile. As it
# finds host targets, it collection information on host target types.
# #
# @param [Array<AggregateTarget>] aggregate_targets the generated # @param [Array<AggregateTarget>] aggregate_targets the generated
# aggregate targets # aggregate targets
...@@ -265,14 +266,19 @@ module Pod ...@@ -265,14 +266,19 @@ module Pod
# @param [Array<AggregateTarget>] embedded_aggregate_targets the aggregate targets # @param [Array<AggregateTarget>] embedded_aggregate_targets the aggregate targets
# representing the embedded targets to be integrated # representing the embedded targets to be integrated
# #
def verify_host_targets_in_podfile(aggregate_targets, embedded_aggregate_targets) def analyze_host_targets_in_podfile(aggregate_targets, embedded_aggregate_targets)
aggregate_target_uuids = Set.new aggregate_targets.map(&:user_targets).flatten.map(&:uuid) aggregate_target_uuids = Set.new aggregate_targets.map(&:user_targets).flatten.map(&:uuid)
aggregate_target_user_projects = aggregate_targets.map(&:user_project) aggregate_target_user_projects = aggregate_targets.map(&:user_project)
embedded_targets_missing_hosts = [] embedded_targets_missing_hosts = []
embedded_aggregate_targets.each do |target| embedded_aggregate_targets.each do |target|
host_uuids = aggregate_target_user_projects.product(target.user_targets).map do |user_project, user_target| host_uuids = []
user_project.host_targets_for_embedded_target(user_target).map(&:uuid) aggregate_target_user_projects.product(target.user_targets).each do |user_project, user_target|
end.flatten host_targets = user_project.host_targets_for_embedded_target(user_target)
host_targets.map(&:product_type).each do |product_type|
target.add_host_target_product_type(product_type)
end
host_uuids += host_targets.map(&:uuid)
end
embedded_targets_missing_hosts << target unless host_uuids.any? do |uuid| embedded_targets_missing_hosts << target unless host_uuids.any? do |uuid|
aggregate_target_uuids.include? uuid aggregate_target_uuids.include? uuid
end end
...@@ -295,7 +301,7 @@ module Pod ...@@ -295,7 +301,7 @@ module Pod
if installation_options.integrate_targets? if installation_options.integrate_targets?
# Copy embedded target pods that cannot have their pods embedded as frameworks to their host targets # Copy embedded target pods that cannot have their pods embedded as frameworks to their host targets
embedded_targets = aggregate_targets.select(&:requires_host_target?).select(&:requires_frameworks?) embedded_targets = aggregate_targets.select(&:requires_host_target?).select(&:requires_frameworks?)
verify_host_targets_in_podfile(aggregate_targets, embedded_targets) analyze_host_targets_in_podfile(aggregate_targets, embedded_targets)
aggregate_targets.each do |target| aggregate_targets.each do |target|
copy_embedded_target_pod_targets_to_host(target, embedded_targets) copy_embedded_target_pod_targets_to_host(target, embedded_targets)
end end
......
...@@ -24,6 +24,21 @@ module Pod ...@@ -24,6 +24,21 @@ module Pod
@search_paths_aggregate_targets = [] @search_paths_aggregate_targets = []
@file_accessors = [] @file_accessors = []
@xcconfigs = {} @xcconfigs = {}
@host_target_types = [] # Product types of the host target, if this target is embedded
end
# Adds product type to the list of product types for the host
# targets, in which this target will be embedded
#
# @param [Symbol] Product type of a host, in which this target
# will be embedded
#
# @note This is important for messages extensions, since a messages
# extension has its frameworks embedded in its host when
# its host is an app but not when it's a messages app
#
def add_host_target_product_type(product_type)
@host_target_types << product_type
end end
# @return [Boolean] True if the user_target's pods are # @return [Boolean] True if the user_target's pods are
...@@ -39,7 +54,7 @@ module Pod ...@@ -39,7 +54,7 @@ module Pod
return false if user_project.nil? return false if user_project.nil?
symbol_types = user_targets.map(&:symbol_type).uniq symbol_types = user_targets.map(&:symbol_type).uniq
raise ArgumentError, "Expected single kind of user_target for #{name}. Found #{symbol_types.join(', ')}." unless symbol_types.count == 1 raise ArgumentError, "Expected single kind of user_target for #{name}. Found #{symbol_types.join(', ')}." unless symbol_types.count == 1
EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.include? symbol_types[0] EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.include?(symbol_types[0]) && !@host_target_types.include?(:messages_application)
end end
# @return [String] the label for the target. # @return [String] the label for the target.
......
...@@ -224,6 +224,12 @@ module Pod ...@@ -224,6 +224,12 @@ module Pod
@target.requires_host_target?.should == true @target.requires_host_target?.should == true
end end
it 'does not require a host target for messages extension targets embedded in messages applications' do
@target.add_host_target_product_type(:messages_application)
@target.user_targets.first.stubs(:symbol_type).returns(:messages_extension)
@target.requires_host_target?.should == false
end
it 'does not require a host target for watch 2 extension targets' do it 'does not require a host target for watch 2 extension targets' do
@target.user_targets.first.stubs(:symbol_type).returns(:watch2_extension) @target.user_targets.first.stubs(:symbol_type).returns(:watch2_extension)
@target.requires_host_target?.should == false @target.requires_host_target?.should == false
......
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