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 #742

Closed
wants to merge 3 commits into from
Closed
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
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: 34 additions & 0 deletions lib/xcodeproj/project/object/native_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,40 @@ def add_resources(resource_file_references)
end
end

# Remove on demand resource to the resources build phase of the target.
#
# @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_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 to the resources build phase of 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_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

# Finds or creates the headers build phase of the target.
#
# @note A target should have only one headers build phase.
Expand Down