Commit 49b4b5af authored by Samuel Giddins's avatar Samuel Giddins Committed by GitHub

Merge pull request #5760 from benasher44/swift_version_resolved_setting

Use the project-level swift version when not defined at the target-level
parents 1bf33827 3ce3c4a1
...@@ -38,6 +38,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -38,6 +38,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Danielle Tomlinson](https://github.com/dantoml) [Danielle Tomlinson](https://github.com/dantoml)
[#5686](https://github.com/CocoaPods/CocoaPods/issues/5686) [#5686](https://github.com/CocoaPods/CocoaPods/issues/5686)
* Fix SWIFT_VERSION not being read when only defined at the project level.
[Ben Asher](https://github.com/benasher44)
[#5700](https://github.com/CocoaPods/CocoaPods/issues/5700) and [#5737](https://github.com/CocoaPods/CocoaPods/issues/5737)
## 1.1.0.beta.1 (2016-07-11) ## 1.1.0.beta.1 (2016-07-11)
......
...@@ -216,10 +216,9 @@ module Pod ...@@ -216,10 +216,9 @@ module Pod
# @return [String] the targets Swift version or nil # @return [String] the targets Swift version or nil
# #
def compute_swift_version_from_targets(targets) def compute_swift_version_from_targets(targets)
versions = targets.flat_map(&:build_configurations). versions = targets.flat_map do |target|
flat_map { |config| config.build_settings['SWIFT_VERSION'] }. target.resolved_build_setting('SWIFT_VERSION').values
compact. end.flatten.compact.uniq
uniq
case versions.count case versions.count
when 0 when 0
nil nil
......
...@@ -326,6 +326,17 @@ module Pod ...@@ -326,6 +326,17 @@ module Pod
target_inspector.send(:compute_swift_version_from_targets, user_targets) target_inspector.send(:compute_swift_version_from_targets, user_targets)
end.message.should.include 'There may only be up to 1 unique SWIFT_VERSION per target.' end.message.should.include 'There may only be up to 1 unique SWIFT_VERSION per target.'
end end
it 'returns the project-level SWIFT_VERSION if the target-level SWIFT_VERSION is not defined' do
user_project = Xcodeproj::Project.new('path')
user_project.build_configuration_list.set_setting('SWIFT_VERSION', '2.3')
target = user_project.new_target(:application, 'Target', :ios)
target_definition = Podfile::TargetDefinition.new(:default, nil)
user_targets = [target]
target_inspector = TargetInspector.new(target_definition, config.installation_root)
target_inspector.send(:compute_swift_version_from_targets, user_targets).should.equal '2.3'
end
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment