Skip to content

Commit

Permalink
allow to reuse external source specification in Podifle
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-makarov committed Dec 7, 2019
1 parent 5a3a871 commit d67843a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/cocoapods-core/podfile/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,19 @@ def install!(installation_method, options = {})
#
# pod 'JSONKit', :podspec => 'https://example.com/JSONKit.podspec'
#
# ### Use a previously defined external source.
#
# If a dependency was already defined using an external source, reuse that definition:
#
# target 'TargetA' do
# # define an external source for `JSONKit`
# pod 'JSONKit', :podspec => 'https://example.com/JSONKit.podspec'
# end
#
# target 'TargetB' do
# # reuse the previous external source for `JSONKit`
# pod 'JSONKit'
# end
#
# @note This method allow a nil name and the raises to be more
# informative.
Expand All @@ -273,6 +286,18 @@ def pod(name = nil, *requirements)
raise StandardError, 'A dependency requires a name.'
end

if requirements.empty? || requirements.last.is_a?(Hash)
theoretical_dependency = Dependency.new(name, requirements.last)
if theoretical_dependency.external_source.nil?
previously_defined_dependency = dependencies.find do |dependency|
dependency.root_name == theoretical_dependency.root_name && dependency.external_source
end
if previously_defined_dependency
requirements = [previously_defined_dependency.external_source]
end
end
end

current_target_definition.store_pod(name, *requirements)
end

Expand Down

0 comments on commit d67843a

Please sign in to comment.