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

Support On-Demand Resource #622

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 @@ -110,6 +110,12 @@ 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.
#
spec_attr_accessor :on_demand_resources
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would want this to be a Hash that allows Pod authors to specify the tag (see my comment here)

example:

s.on_demand_resources = {
    'Tag1' => ['file1.png', 'file2.png']
}

we also may need to provide a way for Pod authors to specify the category of the tag. The category determines how the resource gets fetched. To quote the docs:

Initial install tags. The resources are downloaded at the same time as the app. The size of the resources is included in the total size for the app in the App Store. The tags can be purged when they are not being accessed by at least one NSBundleResourceRequest object.

Prefetch tag order. The resources start downloading after the app is installed. The tags will be downloaded in the order in which they are listed in the Prefetched tag order group.

Dowloaded only on demand. The tags are downloaded when requested by the app.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. I will refer to your design for implementation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementation f240511


# @return [Hash{String => String}] the Info.plist values for the current specification
#
spec_attr_accessor :info_plist
Expand Down
24 changes: 24 additions & 0 deletions lib/cocoapods-core/specification/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,29 @@ def dependency=(args)

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

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


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

# @!method resource_bundles=(*resource_bundles)
#
# This attribute allows to define the name and the file of the resource
Expand Down Expand Up @@ -1370,6 +1393,7 @@ def dependency=(args)
:file_patterns => true,
:singularize => true


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded?

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

# @!method exclude_files=(exclude_files)
Expand Down
5 changes: 5 additions & 0 deletions lib/cocoapods-core/specification/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ def _validate_weak_frameworks(frameworks)
' specified by its name')
end
end

# Performs validations related to the `on_demand_resources` attribute.
#
def _validate_on_demand_resources(on_demand_resource)
end

# Performs validations related to the `libraries` attribute.
#
Expand Down