Commit 80723d9f authored by Ben Asher's avatar Ben Asher

computing swift version uses PBXNativeTarget#resolved_build_setting

parent 990cd0a9
...@@ -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