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

Sometimes we don't actively rely on related components in order to pu… #747

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions lib/cocoapods-core/specification/consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 30 additions & 2 deletions lib/cocoapods-core/specification/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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’.
#
# ---
Expand Down Expand Up @@ -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)
Expand All @@ -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?
Expand Down