Unverified Commit ec2073bf authored by Samuel Giddins's avatar Samuel Giddins Committed by GitHub

Merge pull request #7488 from CocoaPods/segiddins/fix-archiving-swift-static-libs

Fix archiving when using Swift static libraries
parents 11072aee 1014c973
......@@ -596,17 +596,6 @@ module Pod
flags * ' '
end
# Adds a reference to the given file in the support group of this target.
#
# @param [Pathname] path
# The path of the file to which the reference should be added.
#
# @return [PBXFileReference] the file reference of the added file.
#
def add_file_to_support_group(path)
support_files_group.new_file(path)
end
def apply_xcconfig_file_ref_to_resource_bundle_targets(resource_bundle_targets, xcconfig_file_ref)
resource_bundle_targets.each do |rsrc_target|
rsrc_target.build_configurations.each do |rsrc_bc|
......@@ -706,26 +695,34 @@ module Pod
# Adds a shell script phase, intended only for static library targets that contain swift,
# to copy the ObjC compatibility header (the -Swift.h file that the swift compiler generates)
# to the built products directory. Additionally, the script phase copies the module map, appending a `.Swift`
# submodule that references the (moved) compatibility header.
# submodule that references the (moved) compatibility header. Since the module map has been moved, the umbrella header
# is _also_ copied, so that it is sitting next to the module map. This is necessary for a successful archive build.
#
# @return [Void]
#
def add_swift_static_library_compatibility_header_phase
build_phase = native_target.new_shell_script_build_phase('Copy generated compatibility header')
relative_module_map_path = target.module_map_path.relative_path_from(target.sandbox.root)
relative_umbrella_header_path = target.umbrella_header_path.relative_path_from(target.sandbox.root)
build_phase.shell_script = <<-SH.strip_heredoc
COMPATIBILITY_HEADER_PATH="${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
MODULE_MAP_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap"
ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${COMPATIBILITY_HEADER_PATH}"
ditto "${PODS_ROOT}/#{target.module_map_path.relative_path_from(target.sandbox.root)}" "${MODULE_MAP_PATH}"
ditto "${PODS_ROOT}/#{relative_module_map_path}" "${MODULE_MAP_PATH}"
ditto "${PODS_ROOT}/#{relative_umbrella_header_path}" "${BUILT_PRODUCTS_DIR}"
printf "\\n\\nmodule ${PRODUCT_MODULE_NAME}.Swift {\\n header \\"${COMPATIBILITY_HEADER_PATH}\\"\\n requires objc\\n}\\n" >> "${MODULE_MAP_PATH}"
SH
build_phase.input_paths = %W(
${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h
${PODS_ROOT}/#{target.module_map_path.relative_path_from(target.sandbox.root)}
${PODS_ROOT}/#{relative_module_map_path}
${PODS_ROOT}/#{relative_umbrella_header_path}
)
build_phase.output_paths = %w(
build_phase.output_paths = %W(
${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap
${BUILT_PRODUCTS_DIR}/#{relative_umbrella_header_path.basename}
${BUILT_PRODUCTS_DIR}/Swift\ Compatibility\ Header/${PRODUCT_MODULE_NAME}-Swift.h
)
end
......
......@@ -204,10 +204,10 @@ module Pod
file_ref = add_file_to_support_group(path)
native_target.add_file_references([file_ref])
# Make the umbrella header public
acl = target.requires_frameworks? ? 'Public' : 'Project'
build_file = native_target.headers_build_phase.build_file(file_ref)
build_file.settings ||= {}
build_file.settings['ATTRIBUTES'] = ['Public']
build_file.settings['ATTRIBUTES'] = [acl]
end
end
......
Subproject commit 94fd69236ef1f5c92eca020bd7eb4bd5b34138ce
Subproject commit 6ea6db143cff938564b90b63769bcb40a9aaac8b
......@@ -255,6 +255,28 @@ module Pod
script = support_files_dir + 'Pods-SampleProject-frameworks.sh'
File.exist?(script).should == false
end
it 'installs umbrella headers for swift static libraries' do
@pod_target.stubs(:uses_swift? => true)
@target.stubs(:uses_swift? => true)
@installer.install!
build_files = @installer.target.native_target.headers_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-SampleProject-umbrella.h') }
build_file.should.not.be.nil
build_file.settings.should == { 'ATTRIBUTES' => ['Project'] }
end
it 'installs umbrella headers for frameworks' do
@pod_target.stubs(:requires_frameworks? => true)
@target.stubs(:requires_frameworks? => true)
@installer.install!
build_files = @installer.target.native_target.headers_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-SampleProject-umbrella.h') }
build_file.should.not.be.nil
build_file.settings.should == { 'ATTRIBUTES' => ['Public'] }
end
end
end
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