Skip to content

Commit

Permalink
Improve the implementation for on demand resources
Browse files Browse the repository at this point in the history
  • Loading branch information
JunyiXie committed Apr 26, 2020
1 parent 273142b commit f240511
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -3,7 +3,10 @@
## Master

##### Enhancements

* Support On-Demand Resource
[JunyiXie](https://github.com/JunyiXie)
[#issue_number](https://github.com/CocoaPods/Core/pull/622)

* Add a post_integrate_hook API
[lucasmpaim](https://github.com/lucasmpaim)
[#7432](https://github.com/CocoaPods/CocoaPods/issues/7432)
Expand Down
24 changes: 21 additions & 3 deletions lib/cocoapods-core/specification/consumer.rb
Expand Up @@ -110,9 +110,9 @@ def user_target_xcconfig
merge_values(attr, value_for_attribute(:xcconfig), value_for_attribute(:user_target_xcconfig))
end

# @return [Array<String>] A hash where the key represents the
# paths of the on_demand_resources to copy and the values the paths of
# the on_demand_resources that should be copied.
# @return [Hash{String=>String}]] hash where the keys are the names of
# the on demand resource and the values are their relative file
# patterns.
#
spec_attr_accessor :on_demand_resources

Expand Down Expand Up @@ -479,6 +479,24 @@ def _prepare_resource_bundles(value)
result
end

# Ensures that the file patterns of the on demand resources are contained in
# an array.
#
# @param [String, Array, Hash] value.
# The value of the attribute as specified by the user.
#
# @return [Hash] the resources.
#
def _prepare_on_demand_resources(value)
result = {}
if value
value.each do |key, patterns|
result[key] = [*patterns].compact
end
end
result
end

#-----------------------------------------------------------------------#
end
end
Expand Down
17 changes: 7 additions & 10 deletions lib/cocoapods-core/specification/dsl.rb
Expand Up @@ -1305,24 +1305,21 @@ def dependency=(args)

# @!method on_demand_resources=(on_demand_resources)
#
# A list of on_demand_resources that should be copied into the target bundle.
# A list of on_demand_resource that should be copied into the target bundle.
#
# @example
#
# spec.on_demand_resources = 'Resources/HockeySDK.bundle'
#
# @example
#
# spec.on_demand_resources = ['Images/*.png', 'Sounds/*']
#
# s.on_demand_resources = {
# 'Tag1' => ['file1.png', 'file2.png']
# }
# @param [String, Array<String>] resources
# The on_demand_resources shipped with the Pod.
#
attribute :on_demand_resources,
:container => Array,
:types => [String, Array],
:container => Hash,
:file_patterns => true,
:singularize => true

:singularize => true

#------------------#

Expand Down

0 comments on commit f240511

Please sign in to comment.