Skip to content

Commit 9c31800

Browse files
authored
Merge pull request #474 from Lutzifer/feature/improve_error_message
Improve error messages for podspec dependencies
2 parents acfd38f + 0d96cd5 commit 9c31800

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
##### Enhancements
66

7+
* Better error messages, if unallowed version requirement is specified in Podspec.
8+
[Wolfgang Lutz][https://github.com/lutzifer]
9+
[#466](https://github.com/CocoaPods/Core/pull/474)
10+
711
* DSL for `scheme` support.
812
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
913
[#7577](https://github.com/CocoaPods/CocoaPods/issues/7577)

lib/cocoapods-core/specification/dsl.rb

+14-1
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,21 @@ def dependency(*args)
677677
end
678678
end
679679
unless version_requirements.all? { |req| req.is_a?(String) }
680-
raise Informative, 'Unsupported version requirements'
680+
version_requirements.each do |requirement|
681+
if requirement.is_a?(Hash)
682+
if !requirement[:path].nil?
683+
raise Informative, 'Podspecs cannot specify the source of dependencies. The `:path` option is not supported.'\
684+
' `:path` can be used in the Podfile instead to override global dependencies.'
685+
elsif !requirement[:git].nil?
686+
raise Informative, 'Podspecs cannot specify the source of dependencies. The `:git` option is not supported.'\
687+
' `:git` can be used in the Podfile instead to override global dependencies.'
688+
end
689+
end
690+
end
691+
692+
raise Informative, "Unsupported version requirements. #{version_requirements.inspect} is not valid."
681693
end
694+
682695
attributes_hash['dependencies'] ||= {}
683696
attributes_hash['dependencies'][name] = version_requirements
684697
end

spec/specification/dsl_spec.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,19 @@ module Pod
240240
it 'raises if the requirements are not supported' do
241241
should.raise Informative do
242242
@spec.dependency('SVProgressHUD', :head)
243-
end.message.should.match /Unsupported version requirements/
243+
end.message.should.match /Unsupported version requirements. \[\:head\] is not valid/
244+
end
245+
246+
it 'raises if the requirements specify :git' do
247+
should.raise Informative do
248+
@spec.dependency('SVProgressHUD', :git => 'AnyPath')
249+
end.message.should.match /Podspecs cannot specify the source of dependencies. The `:git` option is not supported.\.*/
250+
end
251+
252+
it 'raises if the requirements specify :path' do
253+
should.raise Informative do
254+
@spec.dependency('SVProgressHUD', :path => 'AnyPath')
255+
end.message.should.match /Podspecs cannot specify the source of dependencies. The `:path` option is not supported.\.*/
244256
end
245257

246258
it 'raises when attempting to assign a value to dependency' do

0 commit comments

Comments
 (0)