diff --git a/lib/cocoapods-core/specification/consumer.rb b/lib/cocoapods-core/specification/consumer.rb index e469504b..44645322 100644 --- a/lib/cocoapods-core/specification/consumer.rb +++ b/lib/cocoapods-core/specification/consumer.rb @@ -229,6 +229,12 @@ def user_target_xcconfig # def dependencies value = value_for_attribute(:dependencies) + + # install/update will contain virtual_dependencies!! + if $*.first == "update" || $*.first == "install" + value_virtual = value_for_attribute(:virtual_dependencies) + value = value.merge(value_virtual) if value_virtual + end value.map do |name, requirements| Dependency.new(name, requirements) end diff --git a/lib/cocoapods-core/specification/dsl.rb b/lib/cocoapods-core/specification/dsl.rb index 0e4499e3..445466df 100644 --- a/lib/cocoapods-core/specification/dsl.rb +++ b/lib/cocoapods-core/specification/dsl.rb @@ -666,6 +666,22 @@ def deployment_target=(*_args) :container => Hash, :inherited => true + #-----------------------------------------------------------------------# + + # if define virtual to 'ture', the virtual_dependencies will save it instead of dependencies; + + # # @Target + # This is to create a new virtual dependency that will be updated to the virtual dependency + # when pod install/update without affecting the component label push + + #-----------------------------------------------------------------------# + + # # @example + # spec.ios.dependency 'MBProgressHUD', '~> 0.5', :virtual => 'true' + attribute :virtual_dependencies, + :container => Hash, + :inherited => true + # Any dependency on other Pods or to a ‘sub-specification’. # # --- @@ -719,6 +735,12 @@ def dependency(*args) Array(configurations_option.delete(:configurations)).map { |c| c.to_s.downcase } end + virtual_option = version_requirements.find { |option| option.is_a?(Hash) && option.key?(:virtual) } + is_virtual = if virtual_option + version_requirements.delete(virtual_option) + (virtual_option&.delete(:virtual)&.to_s&.downcase == 'true') || false + end + dependency_options = version_requirements.reject { |req| req.is_a?(String) } dependency_options.each do |dependency_option| if dependency_option.is_a?(Hash) @@ -734,8 +756,14 @@ def dependency(*args) raise Informative, "Unsupported version requirements. #{version_requirements.inspect} is not valid." end - attributes_hash['dependencies'] ||= {} - attributes_hash['dependencies'][name] = version_requirements + #store dependency to virtual_dependencies if has :virtual + if is_virtual + attributes_hash['virtual_dependencies'] ||= {} + attributes_hash['virtual_dependencies'][name] = version_requirements + else + attributes_hash['dependencies'] ||= {} + attributes_hash['dependencies'][name] = version_requirements + end unless whitelisted_configurations.nil? if (extras = whitelisted_configurations - %w(debug release)) && !extras.empty?