Commit f2118095 authored by Ben Asher's avatar Ben Asher

app extension -> embedded target. include frameworks in target type list

parent ae0e46d7
...@@ -34,7 +34,7 @@ group :development do ...@@ -34,7 +34,7 @@ group :development do
cp_gem 'cocoapods-trunk', 'cocoapods-trunk' cp_gem 'cocoapods-trunk', 'cocoapods-trunk'
cp_gem 'cocoapods-try', 'cocoapods-try' cp_gem 'cocoapods-try', 'cocoapods-try'
cp_gem 'molinillo', 'Molinillo' cp_gem 'molinillo', 'Molinillo'
cp_gem 'xcodeproj', 'Xcodeproj' gem 'xcodeproj', :git => 'https://github.com/benasher44/Xcodeproj', :ref => '42df5c0932e11228f9ad9e901b7cae6205d80fe4'
gem 'cocoapods-dependencies', '~> 1.0.beta.1' gem 'cocoapods-dependencies', '~> 1.0.beta.1'
......
...@@ -22,16 +22,6 @@ GIT ...@@ -22,16 +22,6 @@ GIT
specs: specs:
molinillo (0.5.0) molinillo (0.5.0)
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 1b15f4c79303843e8f370afa9dd74b8ad0329785
branch: master
specs:
xcodeproj (1.1.0)
activesupport (>= 3)
claide (>= 1.0.0, < 2.0)
colored (~> 1.2)
GIT GIT
remote: https://github.com/CocoaPods/cocoapods-deintegrate.git remote: https://github.com/CocoaPods/cocoapods-deintegrate.git
revision: c5e0698f7043b440a0d9d2db89f2145171ae6593 revision: c5e0698f7043b440a0d9d2db89f2145171ae6593
...@@ -84,6 +74,16 @@ GIT ...@@ -84,6 +74,16 @@ GIT
specs: specs:
cocoapods-try (1.0.0) cocoapods-try (1.0.0)
GIT
remote: https://github.com/benasher44/Xcodeproj
revision: 42df5c0932e11228f9ad9e901b7cae6205d80fe4
ref: 42df5c0932e11228f9ad9e901b7cae6205d80fe4
specs:
xcodeproj (1.1.0)
activesupport (>= 3)
claide (>= 1.0.0, < 2.0)
colored (~> 1.2)
GIT GIT
remote: https://github.com/segiddins/json.git remote: https://github.com/segiddins/json.git
revision: d4011cabfaa80e9b0da81947b5e9b38dd47359db revision: d4011cabfaa80e9b0da81947b5e9b38dd47359db
......
...@@ -61,13 +61,13 @@ module Pod ...@@ -61,13 +61,13 @@ module Pod
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ', 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ',
'LIBRARY_SEARCH_PATHS' => '$(inherited) ', 'LIBRARY_SEARCH_PATHS' => '$(inherited) ',
} }
# Because app extensions live in their host app, CocoaPods # For embedded targets, which live in a host target, CocoaPods
# copies all of the app extension's pod_targets to the host # copies all of the embedded target's pod_targets its host
# app. Therefore, this check will properly require the Swift # target. Therefore, this check will properly require the Swift
# libs in the host app, if the app extension has any pod targets # libs in the host target, if the embedded target has any pod targets
# that use swift. Setting this for the app extension target would # that use Swift. Setting this for the embedded target would
# cause an App Store rejection because frameworks cannot be embedded # cause an App Store rejection because frameworks cannot be embedded
# in app extensions. # in embedded targets.
if !target.requires_host_target? && pod_targets.any?(&:uses_swift?) if !target.requires_host_target? && pod_targets.any?(&:uses_swift?)
config['EMBEDDED_CONTENT_CONTAINS_SWIFT'] = 'YES' config['EMBEDDED_CONTENT_CONTAINS_SWIFT'] = 'YES'
end end
......
...@@ -226,56 +226,58 @@ module Pod ...@@ -226,56 +226,58 @@ module Pod
private private
# Copies the pod_targets of any of the app extension aggregate targets into # Copies the pod_targets of any of the app embedded aggregate targets into
# their potential host aggregate target, if that potential host aggregate target's # their potential host aggregate target, if that potential host aggregate target's
# user_target hosts any of the app extension aggregate targets' user_targets # user_target hosts any of the app embedded aggregate targets' user_targets
# #
# @param [AggregateTarget] aggregate_target the aggregate target whose user_target # @param [AggregateTarget] aggregate_target the aggregate target whose user_target
# might host one or more of the app extension aggregate targets' user_targets # might host one or more of the embedded aggregate targets' user_targets
# #
# @param [Array<AggregateTarget>] extension_aggregate_targets the aggregate targets # @param [Array<AggregateTarget>] embedded_aggregate_targets the aggregate targets
# representing the app extension targets to be integrated # representing the embedded targets to be integrated
# #
def copy_extension_pod_targets_to_host(aggregate_target, extension_aggregate_targets) def copy_embedded_target_pod_targets_to_host(aggregate_target, embedded_aggregate_targets)
return if aggregate_target.requires_host_target? return if aggregate_target.requires_host_target?
# Get the uuids of the aggregate_target's user_targets' extension targets if any # Get the uuids of the aggregate_target's user_targets' embedded targets if any
extension_uuids = aggregate_target.user_targets.map do |target| embedded_uuids = Set.new(aggregate_target.user_targets.map do |target|
aggregate_target.user_project.extensions_for_native_target(target).map(&:uuid) aggregate_target.user_project.embedded_targets_in_native_target(target).map(&:uuid)
end.flatten end.flatten)
return if extension_uuids.empty? return if embedded_uuids.empty?
extension_aggregate_targets.each do |extension_target| embedded_aggregate_targets.each do |embedded_target|
next unless extension_uuids.include? extension_target.user_targets[0].uuid next unless embedded_target.user_targets.map(&:uuid).any? do |embedded_uuid|
raise Informative, "#{aggregate_target.name} must call use_frameworks! because it is hosting an extension that calls use_frameworks!." unless aggregate_target.requires_frameworks? embedded_uuids.include? embedded_uuid
end
raise Informative, "#{aggregate_target.name} must call use_frameworks! because it is hosting an embedded target that calls use_frameworks!." unless aggregate_target.requires_frameworks?
pod_target_names = aggregate_target.pod_targets.map(&:name) pod_target_names = aggregate_target.pod_targets.map(&:name)
# This extension target is hosted by the aggregate target's user_target; copy over the non-duplicate pod_targets # This embedded target is hosted by the aggregate target's user_target; copy over the non-duplicate pod_targets
aggregate_target.pod_targets = aggregate_target.pod_targets + extension_target.pod_targets.select do |pod_target| aggregate_target.pod_targets = aggregate_target.pod_targets + embedded_target.pod_targets.select do |pod_target|
!pod_target_names.include? pod_target.name !pod_target_names.include? pod_target.name
end end
end end
end end
# Raises an error if there are extension 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
# #
# @param [Array<AggregateTarget>] aggregate_targets the generated # @param [Array<AggregateTarget>] aggregate_targets the generated
# aggregate targets # aggregate targets
# #
# @param [Array<AggregateTarget>] extension_aggregate_targets the aggregate targets # @param [Array<AggregateTarget>] embedded_aggregate_targets the aggregate targets
# representing the app extension targets to be integrated # representing the embedded targets to be integrated
# #
def verify_host_targets_in_podfile(aggregate_targets, extension_aggregate_targets) def verify_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)
extension_targets_missing_hosts = [] embedded_targets_missing_hosts = []
extension_aggregate_targets.each do |target| embedded_aggregate_targets.each do |target|
host_uuids = target.user_targets.map do |user_target| host_uuids = target.user_targets.map do |user_target|
target.user_project.host_targets_for_extension_target(user_target).map(&:uuid) target.user_project.host_targets_for_embedded_target(user_target).map(&:uuid)
end.flatten end.flatten
extension_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
end end
unless extension_targets_missing_hosts.empty? unless embedded_targets_missing_hosts.empty?
raise Informative, "Unable to find host target for #{extension_targets_missing_hosts.map(&:name).join(', ')}. Please add the host targets for the extensions to the Podfile." raise Informative, "Unable to find host target for #{embedded_targets_missing_hosts.map(&:name).join(', ')}. Please add the host targets for the embedded targets to the Podfile."
end end
end end
...@@ -290,11 +292,11 @@ module Pod ...@@ -290,11 +292,11 @@ module Pod
generate_target(target_definition, pod_targets) generate_target(target_definition, pod_targets)
end end
if installation_options.integrate_targets? if installation_options.integrate_targets?
# Copy extension 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
extension_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, extension_targets) verify_host_targets_in_podfile(aggregate_targets, embedded_targets)
aggregate_targets.each do |target| aggregate_targets.each do |target|
copy_extension_pod_targets_to_host(target, extension_targets) copy_embedded_target_pod_targets_to_host(target, embedded_targets)
end end
end end
aggregate_targets.each do |target| aggregate_targets.each do |target|
......
...@@ -116,10 +116,9 @@ module Pod ...@@ -116,10 +116,9 @@ module Pod
# Removes the embed frameworks build phase from app extension targets # Removes the embed frameworks build phase from app extension targets
# #
# @note Older versions of CocoaPods would add this build phase to app # @note Older versions of CocoaPods would add this build phase to embedded
# extension targets. They should be removed on upgrade because app # targets. They should be removed on upgrade because embedded targets
# extension targets will have their frameworks embedded in their host # will have their frameworks embedded in their host targets.
# apps.
# #
def remove_embed_frameworks_script_phase_from_app_extensions def remove_embed_frameworks_script_phase_from_app_extensions
native_targets.each do |native_target| native_targets.each do |native_target|
......
...@@ -8,7 +8,7 @@ module Pod ...@@ -8,7 +8,7 @@ module Pod
attr_reader :target_definition attr_reader :target_definition
# Product types where the product's frameworks must be embedded in a host target # Product types where the product's frameworks must be embedded in a host target
EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES = [:app_extension, :watch_extension].freeze EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES = [:app_extension, :watch_extension, :framework].freeze
# Initialize a new instance # Initialize a new instance
# #
......
...@@ -725,7 +725,7 @@ module Pod ...@@ -725,7 +725,7 @@ module Pod
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile) analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile)
should.raise Informative do should.raise Informative do
analyzer.analyze analyzer.analyze
end.message.should.match /Unable to find host target for Pods-Today Extension. Please add the host targets for the extensions to the Podfile/ end.message.should.match /Unable to find host target for Pods-Today Extension. Please add the host targets for the embedded targets to the Podfile/
end end
it 'raises when the extension calls use_frameworks!, but the host target does not' do it 'raises when the extension calls use_frameworks!, but the host target does not' do
...@@ -746,7 +746,7 @@ module Pod ...@@ -746,7 +746,7 @@ module Pod
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile) analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile)
should.raise Informative do should.raise Informative do
analyzer.analyze analyzer.analyze
end.message.should.match /Pods-Sample Extensions Project must call use_frameworks! because it is hosting an extension that calls use_frameworks!/ end.message.should.match /Pods-Sample Extensions Project must call use_frameworks! because it is hosting an embedded target that calls use_frameworks!/
end end
end end
......
...@@ -214,6 +214,11 @@ module Pod ...@@ -214,6 +214,11 @@ module Pod
@target.requires_host_target?.should == true @target.requires_host_target?.should == true
end end
it 'requires a host target for framework targets' do
@target.user_targets.first.stubs(:symbol_type).returns(:framework)
@target.requires_host_target?.should == true
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