Skip to content

Commit

Permalink
Merge pull request #474 from Lutzifer/feature/improve_error_message
Browse files Browse the repository at this point in the history
Improve error messages  for podspec dependencies
  • Loading branch information
amorde authored Dec 19, 2018
2 parents acfd38f + 0d96cd5 commit 9c31800
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

##### Enhancements

* Better error messages, if unallowed version requirement is specified in Podspec.
[Wolfgang Lutz][https://github.com/lutzifer]
[#466](https://github.com/CocoaPods/Core/pull/474)

* DSL for `scheme` support.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7577](https://github.com/CocoaPods/CocoaPods/issues/7577)
Expand Down
15 changes: 14 additions & 1 deletion lib/cocoapods-core/specification/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,21 @@ def dependency(*args)
end
end
unless version_requirements.all? { |req| req.is_a?(String) }
raise Informative, 'Unsupported version requirements'
version_requirements.each do |requirement|
if requirement.is_a?(Hash)
if !requirement[:path].nil?
raise Informative, 'Podspecs cannot specify the source of dependencies. The `:path` option is not supported.'\
' `:path` can be used in the Podfile instead to override global dependencies.'
elsif !requirement[:git].nil?
raise Informative, 'Podspecs cannot specify the source of dependencies. The `:git` option is not supported.'\
' `:git` can be used in the Podfile instead to override global dependencies.'
end
end
end

raise Informative, "Unsupported version requirements. #{version_requirements.inspect} is not valid."
end

attributes_hash['dependencies'] ||= {}
attributes_hash['dependencies'][name] = version_requirements
end
Expand Down
14 changes: 13 additions & 1 deletion spec/specification/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,19 @@ module Pod
it 'raises if the requirements are not supported' do
should.raise Informative do
@spec.dependency('SVProgressHUD', :head)
end.message.should.match /Unsupported version requirements/
end.message.should.match /Unsupported version requirements. \[\:head\] is not valid/
end

it 'raises if the requirements specify :git' do
should.raise Informative do
@spec.dependency('SVProgressHUD', :git => 'AnyPath')
end.message.should.match /Podspecs cannot specify the source of dependencies. The `:git` option is not supported.\.*/
end

it 'raises if the requirements specify :path' do
should.raise Informative do
@spec.dependency('SVProgressHUD', :path => 'AnyPath')
end.message.should.match /Podspecs cannot specify the source of dependencies. The `:path` option is not supported.\.*/
end

it 'raises when attempting to assign a value to dependency' do
Expand Down

0 comments on commit 9c31800

Please sign in to comment.