Skip to content

Commit

Permalink
[XCConfigIntegrator] Add spec for re-integrating when old config was …
Browse files Browse the repository at this point in the history
…in the CocoaPods sandbox
  • Loading branch information
segiddins committed Dec 4, 2015
1 parent 629b02f commit 615d076
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Expand Up @@ -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 ' \
Expand All @@ -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

Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 615d076

Please sign in to comment.