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
# @return [String] the targets Swift version or nil
#
def compute_swift_version_from_targets(targets)
versions = targets.flat_map(&:build_configurations).
flat_map { |config| config.build_settings['SWIFT_VERSION'] }.
compact.
uniq
versions = targets.flat_map do |target|
target.resolved_build_setting('SWIFT_VERSION').values
end.flatten.compact.uniq
case versions.count
when 0
nil
......
......@@ -326,6 +326,17 @@ module Pod
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
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
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