Commit ee5e8fd4 authored by Kyle Fuller's avatar Kyle Fuller

Merge pull request #3327 from dtorres/aggregate-target-uniq

[AggregateTargetInstaller] Unique resources passed to the script generator
parents a892a5a9 ff16d3f3
...@@ -4,6 +4,15 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -4,6 +4,15 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
To install release candidates run `[sudo] gem install cocoapods --pre` To install release candidates run `[sudo] gem install cocoapods --pre`
## Master
#### Enhancements
* Unique resources passed to the script generator
[Diego Torres](https://github.com/dtorres)
[#3315](https://github.com/CocoaPods/CocoaPods/issues/3315)
[#3327](https://github.com/CocoaPods/CocoaPods/issues/3327)
## 0.36.1 ## 0.36.1
[Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.23.0...0.23.1) [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.23.0...0.23.1)
......
...@@ -102,16 +102,11 @@ module Pod ...@@ -102,16 +102,11 @@ module Pod
end end
end end
# Creates a script that copies the resources to the bundle of the client # Uniqued Resources grouped by config
# target.
# #
# @note The bridge support file needs to be created before the prefix # @return [Hash{ Symbol => Array<Pathname> }]
# header, otherwise it will not be added to the resources script.
# #
# @return [void] def resources_by_config
#
def create_copy_resources_script
path = target.copy_resources_script_path
library_targets = target.pod_targets.reject do |pod_target| library_targets = target.pod_targets.reject do |pod_target|
pod_target.should_build? && pod_target.requires_frameworks? pod_target.should_build? && pod_target.requires_frameworks?
end end
...@@ -120,9 +115,21 @@ module Pod ...@@ -120,9 +115,21 @@ module Pod
file_accessors = library_targets.select { |t| t.include_in_build_config?(config) }.flat_map(&:file_accessors) file_accessors = library_targets.select { |t| t.include_in_build_config?(config) }.flat_map(&:file_accessors)
resource_paths = file_accessors.flat_map { |accessor| accessor.resources.flat_map { |res| res.relative_path_from(project.path.dirname) } } resource_paths = file_accessors.flat_map { |accessor| accessor.resources.flat_map { |res| res.relative_path_from(project.path.dirname) } }
resource_bundles = file_accessors.flat_map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name.shellescape}.bundle" } } resource_bundles = file_accessors.flat_map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name.shellescape}.bundle" } }
resources_by_config[config] = resource_paths + resource_bundles resources_by_config[config] = (resource_paths + resource_bundles).uniq
resources_by_config[config] << bridge_support_file if bridge_support_file resources_by_config[config] << bridge_support_file if bridge_support_file
end end
resources_by_config
end
# Creates a script that copies the resources to the bundle of the client
# target.
#
# @note The bridge support file needs to be created before the prefix
# header, otherwise it will not be added to the resources script.
#
# @return [void]
#
def create_copy_resources_script
generator = Generator::CopyResourcesScript.new(resources_by_config, target.platform) generator = Generator::CopyResourcesScript.new(resources_by_config, target.platform)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
......
...@@ -164,6 +164,21 @@ module Pod ...@@ -164,6 +164,21 @@ module Pod
script.read.should.include?('BananaLib.framework') script.read.should.include?('BananaLib.framework')
end end
it 'uniques resources by config' do
a_path = Pathname.new(@project.path.dirname + "/duplicated/path.jpg")
duplicated_paths = [a_path, a_path]
@installer.target.pod_targets.each do |pod_target|
pod_target.file_accessors.each do |accessor|
accessor.stubs(:resources => duplicated_paths)
end
end
resources_by_config = @installer.send(:resources_by_config)
resources_by_config.each_value do |resources|
resources.length.should == 1
resources[0].basename.should == a_path.basename
end
end
it 'does not add pods to the embed frameworks script if they are not to be built' do it 'does not add pods to the embed frameworks script if they are not to be built' do
@pod_target.stubs(:should_build? => false) @pod_target.stubs(:should_build? => false)
@pod_target.stubs(:requires_frameworks? => true) @pod_target.stubs(:requires_frameworks? => true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment