Commit a4f5bdc6 authored by Samuel Giddins's avatar Samuel Giddins

[PodTarget] Only create module maps for targets that define a module

By default, targets integrated as static libraries _will not_ get a module map, unless they opt-in by including `DEFINES_MODULE = YES` in their specification's `pod_target_xcconfig`
parent 847e309e
...@@ -339,13 +339,15 @@ module Pod ...@@ -339,13 +339,15 @@ module Pod
framework_search_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE) framework_search_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
else else
library_search_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE) library_search_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
module_map_file = if dependent_target.uses_swift? if dependent_target.defines_module?
# for swift, we have a custom build phase that copies in the module map, appending the .Swift module module_map_file = if dependent_target.uses_swift?
"${PODS_CONFIGURATION_BUILD_DIR}/#{dependent_target.label}/#{dependent_target.product_module_name}.modulemap" # for swift, we have a custom build phase that copies in the module map, appending the .Swift module
else "${PODS_CONFIGURATION_BUILD_DIR}/#{dependent_target.label}/#{dependent_target.product_module_name}.modulemap"
"${PODS_ROOT}/#{dependent_target.module_map_path.relative_path_from(dependent_target.sandbox.root)}" else
end "${PODS_ROOT}/#{dependent_target.module_map_path.relative_path_from(dependent_target.sandbox.root)}"
module_map_files << %(-fmodule-map-file="#{module_map_file}") end
module_map_files << %(-fmodule-map-file="#{module_map_file}")
end
end end
swift_import_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE) swift_import_paths << dependent_target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
end end
...@@ -356,7 +358,7 @@ module Pod ...@@ -356,7 +358,7 @@ module Pod
end end
other_swift_flags = module_map_files.tap(&:uniq!).flat_map { |f| ['-Xcc', f] } other_swift_flags = module_map_files.tap(&:uniq!).flat_map { |f| ['-Xcc', f] }
if target.is_a?(PodTarget) && !target.requires_frameworks? if target.is_a?(PodTarget) && !target.requires_frameworks? && target.defines_module?
# make it possible for a mixed swift/objc static library to be able to import the objc from within swift # make it possible for a mixed swift/objc static library to be able to import the objc from within swift
other_swift_flags += ['-import-underlying-module', '-Xcc', '-fmodule-map-file="${SRCROOT}/${MODULEMAP_FILE}"'] other_swift_flags += ['-import-underlying-module', '-Xcc', '-fmodule-map-file="${SRCROOT}/${MODULEMAP_FILE}"']
end end
......
...@@ -27,22 +27,24 @@ module Pod ...@@ -27,22 +27,24 @@ module Pod
add_files_to_build_phases add_files_to_build_phases
create_xcconfig_file create_xcconfig_file
create_test_xcconfig_files if target.contains_test_specifications? create_test_xcconfig_files if target.contains_test_specifications?
# TODO: determine if it is safe to unconditionally create (& 'link') module maps & umbrella
# headers for _all_ static libraries -- we've caused bugs by trying to do this in the past if target.defines_module?
create_module_map do |generator| create_module_map do |generator|
generator.headers.concat module_map_additional_headers generator.headers.concat module_map_additional_headers
end end
create_umbrella_header do |generator| create_umbrella_header do |generator|
file_accessors = target.file_accessors file_accessors = target.file_accessors
file_accessors = file_accessors.reject { |f| f.spec.test_specification? } if target.contains_test_specifications? file_accessors = file_accessors.reject { |f| f.spec.test_specification? } if target.contains_test_specifications?
generator.imports += if header_mappings_dir generator.imports += if header_mappings_dir
file_accessors.flat_map(&:public_headers).map do |pathname| file_accessors.flat_map(&:public_headers).map do |pathname|
pathname.relative_path_from(header_mappings_dir) pathname.relative_path_from(header_mappings_dir)
end end
else else
file_accessors.flat_map(&:public_headers).map(&:basename) file_accessors.flat_map(&:public_headers).map(&:basename)
end end
end
end end
if target.requires_frameworks? if target.requires_frameworks?
unless target.static_framework? unless target.static_framework?
create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform) create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform)
...@@ -54,6 +56,7 @@ module Pod ...@@ -54,6 +56,7 @@ module Pod
elsif target.uses_swift? elsif target.uses_swift?
add_swift_static_library_compatibility_header_phase add_swift_static_library_compatibility_header_phase
end end
unless skip_pch?(target.non_test_specs) unless skip_pch?(target.non_test_specs)
path = target.prefix_header_path path = target.prefix_header_path
file_accessors = target.file_accessors.reject { |f| f.spec.test_specification? } file_accessors = target.file_accessors.reject { |f| f.spec.test_specification? }
......
...@@ -146,6 +146,13 @@ module Pod ...@@ -146,6 +146,13 @@ module Pod
end end
it 'adds the sandbox public headers search paths to the xcconfig, with quotes, as system headers' do it 'adds the sandbox public headers search paths to the xcconfig, with quotes, as system headers' do
expected = "$(inherited) -isystem \"#{config.sandbox.public_headers.search_paths(Platform.ios).join('" -isystem "')}\""
@xcconfig.to_hash['OTHER_CFLAGS'].should == expected
end
it 'adds the dependent pods module map file to OTHER_CFLAGS' do
@pod_targets.each { |pt| pt.stubs(:defines_module? => true) }
@xcconfig = @generator.generate
expected = '$(inherited) -fmodule-map-file="${PODS_ROOT}/Headers/Private/BananaLib/BananaLib.modulemap" -isystem "${PODS_ROOT}/Headers/Public/BananaLib"' expected = '$(inherited) -fmodule-map-file="${PODS_ROOT}/Headers/Private/BananaLib/BananaLib.modulemap" -isystem "${PODS_ROOT}/Headers/Public/BananaLib"'
@xcconfig.to_hash['OTHER_CFLAGS'].should == expected @xcconfig.to_hash['OTHER_CFLAGS'].should == expected
end end
......
...@@ -478,7 +478,6 @@ module Pod ...@@ -478,7 +478,6 @@ module Pod
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
'BananaLib-Pods-SampleProject-dummy.m', 'BananaLib-Pods-SampleProject-dummy.m',
'BananaLib-Pods-SampleProject-prefix.pch', 'BananaLib-Pods-SampleProject-prefix.pch',
'BananaLib-Pods-SampleProject.modulemap',
'BananaLib-Pods-SampleProject.xcconfig', 'BananaLib-Pods-SampleProject.xcconfig',
] ]
end end
...@@ -490,7 +489,6 @@ module Pod ...@@ -490,7 +489,6 @@ module Pod
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
'BananaLib-Pods-SampleProject-dummy.m', 'BananaLib-Pods-SampleProject-dummy.m',
'BananaLib-Pods-SampleProject-prefix.pch', 'BananaLib-Pods-SampleProject-prefix.pch',
'BananaLib-Pods-SampleProject.modulemap',
'BananaLib-Pods-SampleProject.xcconfig', 'BananaLib-Pods-SampleProject.xcconfig',
] ]
end end
...@@ -501,6 +499,17 @@ module Pod ...@@ -501,6 +499,17 @@ module Pod
group = @project['Pods/BananaLib/Support Files'] group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
'BananaLib-Pods-SampleProject-dummy.m', 'BananaLib-Pods-SampleProject-dummy.m',
'BananaLib-Pods-SampleProject.xcconfig',
]
end
it 'adds the module map when the target defines a module' do
@pod_target.stubs(:defines_module?).returns(true)
@installer.install!
group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [
'BananaLib-Pods-SampleProject-dummy.m',
'BananaLib-Pods-SampleProject-prefix.pch',
'BananaLib-Pods-SampleProject.modulemap', 'BananaLib-Pods-SampleProject.modulemap',
'BananaLib-Pods-SampleProject.xcconfig', 'BananaLib-Pods-SampleProject.xcconfig',
] ]
...@@ -570,7 +579,6 @@ module Pod ...@@ -570,7 +579,6 @@ module Pod
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
'BananaLib-dummy.m', 'BananaLib-dummy.m',
'BananaLib-prefix.pch', 'BananaLib-prefix.pch',
'BananaLib.modulemap',
'BananaLib.xcconfig', 'BananaLib.xcconfig',
] ]
end end
...@@ -581,6 +589,17 @@ module Pod ...@@ -581,6 +589,17 @@ module Pod
group = @project['Pods/BananaLib/Support Files'] group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
'BananaLib-dummy.m', 'BananaLib-dummy.m',
'BananaLib.xcconfig',
]
end
it 'adds the module map when the target defines a module' do
@pod_target.stubs(:defines_module?).returns(true)
@installer.install!
group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [
'BananaLib-dummy.m',
'BananaLib-prefix.pch',
'BananaLib.modulemap', 'BananaLib.modulemap',
'BananaLib.xcconfig', 'BananaLib.xcconfig',
] ]
......
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