Commit 7522194f authored by Samuel E. Giddins's avatar Samuel E. Giddins

[TargetIntegrator] Ensure the project is saved when needed

Addresses a regression introduced in https://github.com/CocoaPods/CocoaPods/pull/2601
parent 00af7a5d
...@@ -27,8 +27,8 @@ module Pod ...@@ -27,8 +27,8 @@ module Pod
# #
def integrate! def integrate!
UI.section(integration_message) do UI.section(integration_message) do
XCConfigIntegrator.integrate(target, native_targets) user_project.save if XCConfigIntegrator.integrate(target, native_targets)
update_to_cocoapods_0_34 user_project.save if update_to_cocoapods_0_34
unless native_targets_to_integrate.empty? unless native_targets_to_integrate.empty?
add_pods_library add_pods_library
...@@ -52,6 +52,8 @@ module Pod ...@@ -52,6 +52,8 @@ module Pod
# Fixes the paths of the copy resource scripts. # Fixes the paths of the copy resource scripts.
# #
# @return [Bool] whether any changes to the project were made.
#
# @todo This can be removed for CocoaPods 1.0 # @todo This can be removed for CocoaPods 1.0
# #
def update_to_cocoapods_0_34 def update_to_cocoapods_0_34
...@@ -62,8 +64,11 @@ module Pod ...@@ -62,8 +64,11 @@ module Pod
end.flatten end.flatten
script_path = target.copy_resources_script_relative_path script_path = target.copy_resources_script_relative_path
phases.each do |phase| shell_script = %("#{script_path}"\n)
phase.shell_script = %("#{script_path}"\n) phases.reduce(false) do |changes, phase|
unless phase.shell_script == shell_script
phase.shell_script = shell_script
end || changes
end end
end end
......
...@@ -15,12 +15,15 @@ module Pod ...@@ -15,12 +15,15 @@ module Pod
# The native targets associated which should be integrated # The native targets associated which should be integrated
# with the Pod bundle. # with the Pod bundle.
# #
# @return [Bool] whether any changes to the project were made.
#
def self.integrate(pod_bundle, targets) def self.integrate(pod_bundle, targets)
targets.each do |target| targets.reduce(false) do |changes, target|
target.build_configurations.each do |config| target.build_configurations.reduce(false) do |c, config|
update_to_cocoapods_0_34(pod_bundle, targets) change = update_to_cocoapods_0_34(pod_bundle, targets)
set_target_xcconfig(pod_bundle, target, config) change = set_target_xcconfig(pod_bundle, target, config) || change
end change || c
end || changes
end end
end end
...@@ -38,11 +41,13 @@ module Pod ...@@ -38,11 +41,13 @@ module Pod
# @param [Array<XcodeProj::PBXNativeTarget>] targets # @param [Array<XcodeProj::PBXNativeTarget>] targets
# The native targets. # The native targets.
# #
# @return [Bool] whether any changes to the project were made.
#
# @todo This can be removed for CocoaPods 1.0 # @todo This can be removed for CocoaPods 1.0
# #
def self.update_to_cocoapods_0_34(pod_bundle, targets) def self.update_to_cocoapods_0_34(pod_bundle, targets)
sandbox = pod_bundle.sandbox sandbox = pod_bundle.sandbox
targets.map(&:project).uniq.each do |project| targets.map(&:project).uniq.reduce(false) do |changes, project|
file_refs = project.files.select do |file_ref| file_refs = project.files.select do |file_ref|
path = file_ref.path.to_s path = file_ref.path.to_s
if File.extname(path) == '.xcconfig' if File.extname(path) == '.xcconfig'
...@@ -57,6 +62,8 @@ module Pod ...@@ -57,6 +62,8 @@ module Pod
file_ref.remove_from_project file_ref.remove_from_project
end end
end end
changes || !file_refs.empty?
end end
end end
...@@ -84,7 +91,8 @@ module Pod ...@@ -84,7 +91,8 @@ module Pod
'all, please either set the base configurations of the target ' \ 'all, please either set the base configurations of the target ' \
"#{target.name}` to `#{path}` or include the `#{path}` in your " \ "#{target.name}` to `#{path}` or include the `#{path}` in your " \
'build configuration.' 'build configuration.'
else false
elsif !file_ref
file_ref ||= group.new_file(path) file_ref ||= group.new_file(path)
config.base_configuration_reference = file_ref config.base_configuration_reference = file_ref
end end
......
...@@ -94,6 +94,8 @@ module Pod ...@@ -94,6 +94,8 @@ module Pod
end end
it 'does not perform the integration if there are no targets to integrate' do it 'does not perform the integration if there are no targets to integrate' do
Installer::UserProjectIntegrator::TargetIntegrator::XCConfigIntegrator.
integrate(@pod_bundle, @target_integrator.send(:native_targets))
@target_integrator.stubs(:native_targets_to_integrate).returns([]) @target_integrator.stubs(:native_targets_to_integrate).returns([])
@target_integrator.expects(:add_pods_library).never @target_integrator.expects(:add_pods_library).never
@target_integrator.expects(:add_copy_resources_script_phase).never @target_integrator.expects(:add_copy_resources_script_phase).never
......
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