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 b29c07a commit 81403b6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## Master

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

* Add new APIs to set testables or entries in schemes.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
Expand Down
34 changes: 19 additions & 15 deletions lib/xcodeproj/project/object/native_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -552,33 +552,37 @@ def add_resources(resource_file_references)
end
end

# remove on demand resource files to the resources build phase of the target.
# Remove on demand resource to the resources build phase of the target.
#
# @param [Array<PBXFileReference>] on_demand_resource_file_references
# @param {String => [Array<PBXFileReference>]} on_demand_resource_tag_files
# the files references of the on demand resources to the target.
#
# @return [void]
#
def remove_on_demand_resources(on_demand_resource_file_references)
on_demand_resource_file_references.each do |file|
resources_build_phase.remove_file_reference(file)
def remove_on_demand_resources(on_demand_resource_tag_files)
on_demand_resource_tag_files.each do |_, files|
files.each do |file|
resources_build_phase.remove_file_reference(file)
end
end
end

# Adds on demand resource files to the resources build phase of the target.
# Adds on demand resource to the resources build phase of the target.
#
# @param [Array<PBXFileReference>] on_demand_resource_file_references
# the files references of the on demand resources to the target.
# @param {String => [Array<PBXFileReference>]} on_demand_resource_tag_files
# the files references of the on demand resource to the target.
#
# @return [void]
#
def add_on_demand_resources(on_demand_resource_file_references)
on_demand_resource_file_references.each do |file|
next if resources_build_phase.include?(file)
build_file = project.new(PBXBuildFile)
build_file.file_ref = file
build_file.settings = (build_file.settings ||= {}).merge({"ASSET_TAGS" => ["OnDemand"]})
resources_build_phase.files << build_file
def add_on_demand_resources(on_demand_resource_tag_files)
on_demand_resource_tag_files.each do |tag_name, files|
files.each do |file|
next if resources_build_phase.include?(file)
build_file = project.new(PBXBuildFile)
build_file.file_ref = file
build_file.settings = (build_file.settings ||= {}).merge('ASSET_TAGS' => [tag_name])
resources_build_phase.files << build_file
end
end
end

Expand Down

0 comments on commit 81403b6

Please sign in to comment.