Xcodeproj icon indicating copy to clipboard operation
Xcodeproj copied to clipboard

resolved_build_setting does not consider variables with same key from project xcconfig

Open dfelber opened this issue 2 years ago • 0 comments

Given a Xcode project with a xcconfig file defining PRODUCT_BUNDLE_IDENTIFIER and targets using the setting with the same key (e.g. $(PRODUCT_BUNDLE_IDENTIFIER).suffix), I would expect the targets to have the variable in the value resolved with the value defined in xcconfig when querying with resolved_build_setting.

#native_target_spec.rb

it 'returns the resolved build setting string value for a given key considering variable substitution: target referencing project xcconfig' do
    project_xcconfig = @project.new_file(fixture_path('project.xcconfig'))
    @project.build_configuration_list.build_configurations.each { |build_config| build_config.base_configuration_reference = project_xcconfig }
    @target.build_configuration_list.set_setting('PRODUCT_BUNDLE_IDENTIFIER', '$(PRODUCT_BUNDLE_IDENTIFIER).suffix')
    expected_value_release = 'com.cocoapods.app.suffix'
    expected_value_debug = 'com.cocoapods.app.dev.suffix'
    @target.resolved_build_setting('PRODUCT_BUNDLE_IDENTIFIER', true).should == { 'Release' => expected_value_release, 'Debug' => expected_value_debug }
end

However, only the value of the xcconfig file is used:

Bacon::Error: {"Release"=>"com.cocoapods.app", "Debug"=>"com.cocoapods.app.dev"}.==({"Release"=>"com.cocoapods.app.suffix", "Debug"=>"com.cocoapods.app.dev.suffix"}) failed

As far as I see, this only happens when using a variable with the same name as the key.

dfelber avatar Jun 10 '22 07:06 dfelber