Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages for podspec dependencies #474

Merged
merged 7 commits into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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