Skip to content

Commit

Permalink
[XCConfigurationList] Ignore nil values in `common_resolved_build_set…
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Oct 10, 2013
1 parent fa095ed commit 733e5cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

###### Enhancements

* [XCConfigurationList] Added default value for `default_configuration_name`
attribute.
* [AbstractTarget] The `#sdk` method now raises if the value is not the same
across all the build configurations.
[Fabio Pelosin](https://github.com/irrationalfab)

* [XCConfigurationList] `common_resolved_build_setting` will now ignore nil
values. This is an heuristic which might not closely match Xcode behaviour.
This is done because some information, like the SDK, is usually considered at
the target level but it might actually differ in the build configurations.
For example nothing prevents a target to build with the iOS sdk in one
configuration and with the OS X in another.
[Fabio Pelosin](https://github.com/irrationalfab)


Expand All @@ -12,7 +20,8 @@
###### Breaking

* [AbstractTarget] The `#sdk` method now raises if the value is not the same
across all the build configurations.
across all the build configurations. This has been done to prevent clients
from accidentally using arbitrary values.
[Fabio Pelosin](https://github.com/irrationalfab)

###### Enhancements
Expand Down
15 changes: 11 additions & 4 deletions lib/xcodeproj/project/object/native_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,19 @@ def resolved_build_setting(key)
#
# @raise If the build setting has multiple values.
#
# @note As it is common not to have a setting with no value for
# custom build configurations nil keys are not considered to
# determine if the setting is unique. This is an heuristic
# which might not closely match Xcode behaviour.
#
# @return [String] The value of the build setting.
#
def common_resolved_build_setting(key)
values = resolved_build_setting(key).values.uniq
if values.count == 1
values = resolved_build_setting(key).values.compact.uniq
if values.count <= 1
values.first
else
raise "Build setting `#{key}` has multiple values: `#{resolved_build_setting(key)}`"
raise "[Xcodeproj] Consistency issue: build setting `#{key}` has multiple values: `#{resolved_build_setting(key)}`"
end
end

Expand All @@ -95,7 +100,9 @@ def platform_name
# @return [String] the version of the SDK.
#
def sdk_version
sdk.scan(/[0-9.]+/).first
if sdk
sdk.scan(/[0-9.]+/).first
end
end

# @return [String] the deployment target of the target according to its
Expand Down

0 comments on commit 733e5cf

Please sign in to comment.