Commit 59ccf4ea authored by Boris Bügling's avatar Boris Bügling Committed by Marius Rackwitz

Bundle Resources into Frameworks

- Do not add resources for Pods which are build as frameworks to the
  copy resources script.
- Set configuration build dir for resource bundle targets so that they
  end up alongside the corresponding frameworks.
- Add resources to framework bundles and embed resource bundles.
parent bced0ec3
......@@ -98,7 +98,10 @@ module Pod
#
def create_copy_resources_script
path = target.copy_resources_script_path
file_accessors = target.pod_targets.map(&:file_accessors).flatten
library_targets = target.pod_targets.reject do |pod_target|
pod_target.should_build? && pod_target.requires_frameworks?
end
file_accessors = library_targets.map(&:file_accessors).flatten
resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.path.dirname) } }.flatten
resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
resources = []
......
......@@ -17,8 +17,8 @@ module Pod
UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target
create_support_files_dir
add_files_to_build_phases
add_resources_bundle_targets
add_files_to_build_phases
create_xcconfig_file
if target.requires_frameworks?
create_info_plist_file
......@@ -75,6 +75,22 @@ module Pod
other_file_refs = other_source_files.map { |sf| project.reference_for_path(sf) }
native_target.add_file_references(other_file_refs, nil)
next unless target.requires_frameworks?
resource_refs = file_accessor.resources.flatten.map do |res|
project.new_file(res.relative_path_from(project.path.dirname))
end
project.products_group.files.each do |product_ref|
file_accessor.resource_bundles.keys.each do |bundle_name|
if product_ref.path == "#{bundle_name}.bundle"
resource_refs << product_ref
end
end
end
native_target.add_resources(resource_refs)
end
end
......@@ -106,6 +122,12 @@ module Pod
if target.should_build?
native_target.add_dependency(bundle_target)
end
if target.requires_frameworks?
bundle_target.build_configurations.each do |c|
c.build_settings['CONFIGURATION_BUILD_DIR'] = target.configuration_build_dir
end
end
end
end
end
......
......@@ -134,6 +134,14 @@ module Pod
script.read.should.include?('logo-sidebar.png')
end
it 'does not add framework resource to copy resources script' do
@pod_target.stubs(:requires_frameworks? => true)
@installer.install!
support_files_dir = config.sandbox.target_support_files_dir('Pods')
script = support_files_dir + 'Pods-resources.sh'
script.read.should.not.include?('logo-sidebar.png')
end
xit 'adds the resources bundles to the copy resources script' do
end
......
......@@ -103,6 +103,15 @@ module Pod
@project.targets.map(&:name).should == ['Pods-BananaLib', 'banana_bundle']
end
it 'adds framework resources to the framework target' do
@pod_target.stubs(:requires_frameworks? => true)
@installer.install!
resources = @project.targets.first.resources_build_phase.files
resources.count.should > 0
resource = resources.find { |res| res.file_ref.path.include?('logo-sidebar.png') }
resource.should.be.not.nil
end
xit 'adds the build configurations to the resources bundle targets' do
end
......
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