Commit 22ff2516 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #4028 from CocoaPods/mr-target-integrator-migration

[TargetIntegrator] Remove embed frameworks build phase where not needed
parents b8f6bd87 9794feae
...@@ -46,6 +46,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -46,6 +46,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[#3190](https://github.com/CocoaPods/CocoaPods/issues/3190) [#3190](https://github.com/CocoaPods/CocoaPods/issues/3190)
[#3792](https://github.com/CocoaPods/CocoaPods/pull/3792) [#3792](https://github.com/CocoaPods/CocoaPods/pull/3792)
* Remove embed frameworks build phase from target types, where it is not required.
[Marius Rackwitz](https://github.com/mrackwitz)
[#3905](https://github.com/CocoaPods/CocoaPods/issues/3905)
[#4028](https://github.com/CocoaPods/CocoaPods/pull/4028)
## 0.38.2 ## 0.38.2
......
...@@ -14,6 +14,10 @@ module Pod ...@@ -14,6 +14,10 @@ module Pod
# #
EMBED_FRAMEWORK_TARGET_TYPES = [:application, :unit_test_bundle].freeze EMBED_FRAMEWORK_TARGET_TYPES = [:application, :unit_test_bundle].freeze
# @return [String] the name of the embed frameworks phase
#
EMBED_FRAMEWORK_PHASE_NAME = 'Embed Pods Frameworks'.freeze
# @return [AggregateTarget] the target that should be integrated. # @return [AggregateTarget] the target that should be integrated.
# #
attr_reader :target attr_reader :target
...@@ -38,6 +42,7 @@ module Pod ...@@ -38,6 +42,7 @@ module Pod
project_is_dirty = [ project_is_dirty = [
XCConfigIntegrator.integrate(target, native_targets), XCConfigIntegrator.integrate(target, native_targets),
update_to_cocoapods_0_34, update_to_cocoapods_0_34,
update_to_cocoapods_0_37_1,
remove_embed_frameworks_script_phases, remove_embed_frameworks_script_phases,
unless native_targets_to_integrate.empty? unless native_targets_to_integrate.empty?
add_pods_library add_pods_library
...@@ -100,6 +105,18 @@ module Pod ...@@ -100,6 +105,18 @@ module Pod
changes changes
end end
# Removes the embed frameworks phase for target types.
#
# @return [Bool] whether any changes to the project were made.
#
# @todo This can be removed for CocoaPods 1.0
#
def update_to_cocoapods_0_37_1
(native_targets - native_targets_to_embed_in).any? do |native_target|
remove_embed_frameworks_script_phase(native_target)
end
end
# Adds spec product reference to the frameworks build phase of the # Adds spec product reference to the frameworks build phase of the
# {TargetDefinition} integration libraries. Adds a file reference to # {TargetDefinition} integration libraries. Adds a file reference to
# the frameworks group of the project and adds it to the frameworks # the frameworks group of the project and adds it to the frameworks
...@@ -142,11 +159,8 @@ module Pod ...@@ -142,11 +159,8 @@ module Pod
# @return [void] # @return [void]
# #
def add_embed_frameworks_script_phase def add_embed_frameworks_script_phase
targets_to_embed_in = native_targets_to_integrate.select do |target| native_targets_to_embed_in.each do |native_target|
EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type) phase = create_or_update_build_phase(native_target, EMBED_FRAMEWORK_PHASE_NAME)
end
targets_to_embed_in.each do |native_target|
phase = create_or_update_build_phase(native_target, 'Embed Pods Frameworks')
script_path = target.embed_frameworks_script_relative_path script_path = target.embed_frameworks_script_relative_path
phase.shell_script = %("#{script_path}"\n) phase.shell_script = %("#{script_path}"\n)
end end
...@@ -160,18 +174,22 @@ module Pod ...@@ -160,18 +174,22 @@ module Pod
# #
def remove_embed_frameworks_script_phases def remove_embed_frameworks_script_phases
return false if target.requires_frameworks? return false if target.requires_frameworks?
native_targets.any? do |native_target|
phase_name = 'Embed Pods Frameworks' remove_embed_frameworks_script_phase(native_target)
result = false
native_targets.each do |native_target|
embed_build_phase = native_target.shell_script_build_phases.find { |bp| bp.name == phase_name }
next unless embed_build_phase.present?
native_target.build_phases.delete(embed_build_phase)
result = true
end end
end
result # Delete a 'Embed Pods Frameworks' Copy Files Build Phase if present
#
# @param [PBXNativeTarget] native_target
#
# @return [Bool] whether any changes to the project were made.
#
def remove_embed_frameworks_script_phase(native_target)
embed_build_phase = native_target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
return false unless embed_build_phase.present?
native_target.build_phases.delete(embed_build_phase)
true
end end
# Adds a shell script build phase responsible to copy the resources # Adds a shell script build phase responsible to copy the resources
...@@ -227,6 +245,16 @@ module Pod ...@@ -227,6 +245,16 @@ module Pod
@native_targets ||= target.user_targets(user_project) @native_targets ||= target.user_targets(user_project)
end end
# @return [Array<PBXNativeTarget>] The list of all the targets that
# require that the pod frameworks are embedded in the output
# directory / product bundle.
#
def native_targets_to_embed_in
native_targets_to_integrate.select do |target|
EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type)
end
end
# @return [Array<PBXNativeTarget>] The list of the targets # @return [Array<PBXNativeTarget>] The list of the targets
# that have not been integrated by past installations # that have not been integrated by past installations
# of # of
......
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