From 615d076807f10be837315b00e7fd0b4a22cc8d7a Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Thu, 3 Dec 2015 16:24:26 -0600 Subject: [PATCH] [XCConfigIntegrator] Add spec for re-integrating when old config was in the CocoaPods sandbox --- .../target_integrator/xcconfig_integrator.rb | 10 +++++++--- .../xcconfig_integrator_spec.rb | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb b/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb index a986ef76b8..6690ceac8a 100644 --- a/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +++ b/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb @@ -79,9 +79,14 @@ def self.set_target_xcconfig(pod_bundle, target, config) file_ref = group.files.find { |f| f.path == path } existing = config.base_configuration_reference + set_base_configuration_reference = ->() do + file_ref ||= group.new_file(path) + config.base_configuration_reference = file_ref + end + if existing && existing != file_ref if existing.real_path.to_path.start_with?(pod_bundle.support_files_dir.to_path) - existing.path = path + set_base_configuration_reference.call elsif !xcconfig_includes_target_xcconfig?(config.base_configuration_reference, path) UI.warn 'CocoaPods did not set the base configuration of your ' \ 'project because your project already has a custom ' \ @@ -91,8 +96,7 @@ def self.set_target_xcconfig(pod_bundle, target, config) 'build configuration.' end elsif config.base_configuration_reference.nil? || file_ref.nil? - file_ref ||= group.new_file(path) - config.base_configuration_reference = file_ref + set_base_configuration_reference.call end end diff --git a/spec/unit/installer/user_project_integrator/target_integrator/xcconfig_integrator_spec.rb b/spec/unit/installer/user_project_integrator/target_integrator/xcconfig_integrator_spec.rb index 5574e7cddc..3b7c47cb0d 100644 --- a/spec/unit/installer/user_project_integrator/target_integrator/xcconfig_integrator_spec.rb +++ b/spec/unit/installer/user_project_integrator/target_integrator/xcconfig_integrator_spec.rb @@ -5,7 +5,7 @@ module Pod before do project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') @project = Xcodeproj::Project.open(project_path) - Xcodeproj::Project.new(config.sandbox.project_path).save + Project.new(config.sandbox.project_path).save @target = @project.targets.first target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition.link_with_first_target = true @@ -105,5 +105,20 @@ module Pod UI.warnings.should.not.match /not set.*base configuration/ end + + it 'handles when xcconfig is set to another sandox xcconfig' do + group = @project.new_group('Pods') + old_config = group.new_file('../Pods/Target Support Files/Pods/SampleConfig.xcconfig') + @target.build_configurations.each do |config| + config.base_configuration_reference = old_config + end + XCConfigIntegrator.integrate(@pod_bundle, [@target]) + @target.build_configurations.each do |config| + config.base_configuration_reference.should.not == old_config + config.base_configuration_reference.path.should == @pod_bundle.xcconfig_relative_path(config.name) + end + + UI.warnings.should.be.empty + end end end