Commit 1bdcf205 authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #6750 from atreat/feature/improved-dot-swift-version-validation

 Updates how .swift-version file is validated to prevent it from being needed in Objective-C pods
parents 51575f5f 512372a3
......@@ -16,6 +16,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#1698](https://github.com/CocoaPods/CocoaPods/issues/1698)
* Prevents need for .swift-version file in Objective-C pods
[Austin Emmons](https://github.com/atreat)
[#6742](https://github.com/CocoaPods/CocoaPods/issues/6742)
##### Bug Fixes
* Only check for valid Swift version for pod targets that use Swift
......
......@@ -146,15 +146,8 @@ module Pod
reasons << 'all results apply only to public specs, but you can use ' \
'`--private` to ignore them if linting the specification for a private pod'
end
if dot_swift_version.nil?
reasons.to_sentence + ".\n[!] The validator for Swift projects uses " \
'Swift 3.0 by default, if you are using a different version of ' \
'swift you can use a `.swift-version` file to set the version for ' \
"your Pod. For example to use Swift 2.3, run: \n" \
' `echo "2.3" > .swift-version`'
else
reasons.to_sentence
end
reasons.to_sentence
end
#-------------------------------------------------------------------------#
......@@ -308,6 +301,7 @@ module Pod
download_pod
check_file_patterns
install_pod
validate_dot_swift_version
add_app_project_import
validate_vendored_dynamic_frameworks
build_pod
......@@ -382,6 +376,17 @@ module Pod
validate_url(spec.documentation_url) if spec.documentation_url
end
def validate_dot_swift_version
if !used_swift_version.nil? && dot_swift_version.nil?
warning(:swift_version,
'The validator for Swift projects uses ' \
'Swift 3.0 by default, if you are using a different version of ' \
'swift you can use a `.swift-version` file to set the version for ' \
"your Pod. For example to use Swift 2.3, run: \n" \
' `echo "2.3" > .swift-version`')
end
end
def setup_validation_environment
validation_dir.rmtree if validation_dir.exist?
validation_dir.mkpath
......
......@@ -870,8 +870,14 @@ module Pod
validator
end
it 'fails on deployment target < iOS 8 for Swift Pods' do
def test_swiftpod_with_dot_swift_version(version = '3.1.0')
validator = test_swiftpod
validator.stubs(:dot_swift_version).returns(version)
validator
end
it 'fails on deployment target < iOS 8 for Swift Pods' do
validator = test_swiftpod_with_dot_swift_version
validator.validate
validator.results.map(&:to_s).first.should.match /dynamic frameworks.*iOS > 8/
......@@ -881,7 +887,7 @@ module Pod
it 'succeeds on deployment target < iOS 8 for Swift Pods using XCTest' do
Specification::Consumer.any_instance.stubs(:frameworks).returns(%w(XCTest))
validator = test_swiftpod
validator = test_swiftpod_with_dot_swift_version
validator.validate
validator.results.count.should == 0
end
......@@ -889,27 +895,36 @@ module Pod
it 'succeeds on deployment targets >= iOS 8 for Swift Pods' do
Specification.any_instance.stubs(:deployment_target).returns('9.0')
validator = test_swiftpod
validator = test_swiftpod_with_dot_swift_version
validator.validate
validator.results.count.should == 0
end
it 'tells users about the .swift-version file if the validation fails' do
it 'fails without the presence of a .swift-version file for Swift Pods' do
Specification.any_instance.stubs(:deployment_target).returns('9.0')
validator = test_swiftpod
validator.stubs(:validated?).returns(false)
result = Validator::Result.new(:error, 'attribute', 'message')
validator.stubs(:results).returns([result])
validator.validate
validator.results.count.should == 1
validator.failure_reason.should == "1 error.\n[!] The validator for " \
result = validator.results.first
result.type.should == :warning
result.message.should == 'The validator for ' \
'Swift projects uses Swift 3.0 by default, if you are using a ' \
'different version of swift you can use a `.swift-version` file ' \
'to set the version for your Pod. For example to use Swift 2.3, ' \
"run: \n `echo \"2.3\" > .swift-version`"
end
it 'succeeds with the presence of a .swift-version file for Swift Pods' do
Specification.any_instance.stubs(:deployment_target).returns('9.0')
validator = test_swiftpod_with_dot_swift_version
validator.validate
validator.results.count.should == 0
end
describe '#swift_version' do
it 'defaults to Swift 3.0' do
validator = test_swiftpod
......
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