Skip to content

Commit 4ca29ab

Browse files
committed
Provide option to look into xcconfigs for common build settings.
1 parent 7151d54 commit 4ca29ab

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
##### Enhancements
66

7-
* None.
7+
* Provide option to look into xcconfigs for common build settings.
8+
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
9+
[#722](https://github.com/CocoaPods/Xcodeproj/pull/722)
810

911
##### Bug Fixes
1012

@@ -27,7 +29,6 @@
2729
* Update PBXProject known_regions attribute to include 'Base'
2830
[Liam Nichols](https://github.com/liamnichols)
2931
[#9187](https://github.com/CocoaPods/CocoaPods/issues/9187)
30-
3132

3233
##### Bug Fixes
3334

lib/xcodeproj/project/object/native_target.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AbstractTarget < AbstractObject
4242
# the key of the build setting.
4343
#
4444
# @param [Bool] resolve_against_xcconfig
45-
# wether the resolved setting should take in consideration any
45+
# whether the resolved setting should take in consideration any
4646
# configuration file present.
4747
#
4848
# @return [Hash{String => String}] The value of the build setting
@@ -74,6 +74,10 @@ def resolved_build_setting(key, resolve_against_xcconfig = false)
7474
# @param [String] key
7575
# the key of the build setting.
7676
#
77+
# @param [Boolean] resolve_against_xcconfig
78+
# whether the resolved setting should take in consideration any
79+
# configuration file present.
80+
#
7781
# @raise If the build setting has multiple values.
7882
#
7983
# @note As it is common not to have a setting with no value for
@@ -83,8 +87,8 @@ def resolved_build_setting(key, resolve_against_xcconfig = false)
8387
#
8488
# @return [String] The value of the build setting.
8589
#
86-
def common_resolved_build_setting(key)
87-
values = resolved_build_setting(key).values.compact.uniq
90+
def common_resolved_build_setting(key, resolve_against_xcconfig: false)
91+
values = resolved_build_setting(key, resolve_against_xcconfig).values.compact.uniq
8892
if values.count <= 1
8993
values.first
9094
else

lib/xcodeproj/scheme/test_action.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def code_coverage_enabled?
5858
string_to_bool(@xml_element.attributes['codeCoverageEnabled'])
5959
end
6060

61-
# @rparam [Bool] flag
61+
# @param [Bool] flag
6262
# Set whether Clang Code Coverage is enabled ('Gather coverage data' turned ON)
6363
#
6464
def code_coverage_enabled=(flag)

spec/fixtures/target.xcconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ TARGET_REFERENCE_XCCONFIG_PROJECT = $(USER_DEFINED_XCCONFIG_PROJECT)
1313
A_BUILD_SETTING_WITH_VALUE = Some value
1414
TARGET_REFERENCE_ENVIRONMENT =
1515
TARGET_REFERENCE_ENVIRONMENT_SUBSTITUTION = ${DEFINED_IN_ENVIRONMENT}
16+
17+
APPLICATION_EXTENSION_API_ONLY = YES

spec/project/object/native_target_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ module ProjectSpecs
245245
@target.common_resolved_build_setting('ARCHS').should == 'VALID_ARCHS'
246246
end
247247

248+
it 'returns the common resolved build setting for the given key including xcconfig' do
249+
target_xcconfig = @project.new_file(fixture_path('target.xcconfig'))
250+
@target.build_configuration_list.build_configurations.each { |build_config| build_config.base_configuration_reference = target_xcconfig }
251+
@target.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY', :resolve_against_xcconfig => false).should.be.nil
252+
@target.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY', :resolve_against_xcconfig => true).should == 'YES'
253+
end
254+
248255
it 'raises if the build setting has multiple values across the build configurations' do
249256
@target.build_configuration_list.build_configurations.first.build_settings['ARCHS'] = 'arm64'
250257
@target.build_configuration_list.build_configurations.last.build_settings['ARCHS'] = 'VALID_ARCHS'

0 commit comments

Comments
 (0)