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
#
def integrate!
UI.section(integration_message) do
XCConfigIntegrator.integrate(target, native_targets)
update_to_cocoapods_0_34
user_project.save if XCConfigIntegrator.integrate(target, native_targets)
user_project.save if update_to_cocoapods_0_34
unless native_targets_to_integrate.empty?
add_pods_library
......@@ -52,6 +52,8 @@ module Pod
# 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
#
def update_to_cocoapods_0_34
......@@ -62,8 +64,11 @@ module Pod
end.flatten
script_path = target.copy_resources_script_relative_path
phases.each do |phase|
phase.shell_script = %("#{script_path}"\n)
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
......
......@@ -15,12 +15,15 @@ module Pod
# The native targets associated which should be integrated
# with the Pod bundle.
#
# @return [Bool] whether any changes to the project were made.
#
def self.integrate(pod_bundle, targets)
targets.each do |target|
target.build_configurations.each do |config|
update_to_cocoapods_0_34(pod_bundle, targets)
set_target_xcconfig(pod_bundle, target, config)
end
targets.reduce(false) do |changes, target|
target.build_configurations.reduce(false) do |c, config|
change = update_to_cocoapods_0_34(pod_bundle, targets)
change = set_target_xcconfig(pod_bundle, target, config) || change
change || c
end || changes
end
end
......@@ -38,11 +41,13 @@ module Pod
# @param [Array<XcodeProj::PBXNativeTarget>] targets
# The native targets.
#
# @return [Bool] whether any changes to the project were made.
#
# @todo This can be removed for CocoaPods 1.0
#
def self.update_to_cocoapods_0_34(pod_bundle, targets)
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|
path = file_ref.path.to_s
if File.extname(path) == '.xcconfig'
......@@ -57,6 +62,8 @@ module Pod
file_ref.remove_from_project
end
end
changes || !file_refs.empty?
end
end
......@@ -84,7 +91,8 @@ module Pod
'all, please either set the base configurations of the target ' \
"#{target.name}` to `#{path}` or include the `#{path}` in your " \
'build configuration.'
else
false
elsif !file_ref
file_ref ||= group.new_file(path)
config.base_configuration_reference = file_ref
end
......
......@@ -94,6 +94,8 @@ module Pod
end
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.expects(:add_pods_library).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