File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
lib/cocoapods-core/podfile Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,19 @@ def install!(installation_method, options = {})
262262 #
263263 # pod 'JSONKit', :podspec => 'https://example.com/JSONKit.podspec'
264264 #
265+ # ### Use a previously defined external source.
266+ #
267+ # If a dependency was already defined using an external source, reuse that definition:
268+ #
269+ # target 'TargetA' do
270+ # # define an external source for `JSONKit`
271+ # pod 'JSONKit', :podspec => 'https://example.com/JSONKit.podspec'
272+ # end
273+ #
274+ # target 'TargetB' do
275+ # # reuse the previous external source for `JSONKit`
276+ # pod 'JSONKit'
277+ # end
265278 #
266279 # @note This method allow a nil name and the raises to be more
267280 # informative.
@@ -273,6 +286,18 @@ def pod(name = nil, *requirements)
273286 raise StandardError , 'A dependency requires a name.'
274287 end
275288
289+ if requirements . empty? || requirements . last . is_a? ( Hash )
290+ theoretical_dependency = Dependency . new ( name , requirements . last )
291+ if theoretical_dependency . external_source . nil?
292+ previously_defined_dependency = dependencies . find do |dependency |
293+ dependency . root_name == theoretical_dependency . root_name && dependency . external_source
294+ end
295+ if previously_defined_dependency
296+ requirements = [ previously_defined_dependency . external_source ]
297+ end
298+ end
299+ end
300+
276301 current_target_definition . store_pod ( name , *requirements )
277302 end
278303
You can’t perform that action at this time.
0 commit comments