Commit da046a13 authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7147 from dnkoutso/prefix_header_paths_fix

Fix integration `prefix_header_file` with test specs
parents ba32500f 812b9648
......@@ -30,6 +30,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
* Fix integration `prefix_header_file` with test specs
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7147](https://github.com/CocoaPods/CocoaPods/pull/7147)
* Set the default Swift version to 3.2 during validation
[Victor Hugo Barros](https://github.com/heyzooi)
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
......
......@@ -48,8 +48,17 @@ module Pod
create_build_phase_to_move_static_framework_archive
end
end
unless skip_pch?
create_prefix_header
unless skip_pch?(target.non_test_specs)
path = target.prefix_header_path
file_accessors = target.file_accessors.reject { |f| f.spec.test_specification? }
create_prefix_header(path, file_accessors, target.platform, [native_target])
end
unless skip_pch?(target.test_specs)
target.supported_test_types.each do |test_type|
path = target.prefix_header_path_for_test_type(test_type)
file_accessors = target.file_accessors.select { |f| f.spec.test_specification? }
create_prefix_header(path, file_accessors, target.platform, target.test_native_targets)
end
end
create_dummy_source
end
......@@ -59,8 +68,8 @@ module Pod
# @return [Boolean] Whether the target should build a pch file.
#
def skip_pch?
target.specs.any? { |spec| spec.prefix_header_file.is_a?(FalseClass) }
def skip_pch?(specs)
specs.any? { |spec| spec.prefix_header_file.is_a?(FalseClass) }
end
# Remove the default headers folder path settings for static library pod
......@@ -464,26 +473,39 @@ module Pod
# to the platform of the target. This file also include any prefix header
# content reported by the specification of the pods.
#
# @param [Pathname] path
# the path to generate the prefix header for.
#
# @param [Array<Sandbox::FileAccessor>] file_accessors
# the file accessors to use for this prefix header that point to a path of a prefix header
#
# @param [Platform] platform
# the platform to use for this prefix header.
#
# @param [Array<PBXNativetarget>] native_targets
# the native targets on which the prefix header should be configured for.
#
# @return [void]
#
def create_prefix_header
path = target.prefix_header_path
generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
def create_prefix_header(path, file_accessors, platform, native_targets)
generator = Generator::PrefixHeader.new(file_accessors, platform)
update_changed_file(generator, path)
add_file_to_support_group(path)
native_targets.each do |native_target|
native_target.build_configurations.each do |c|
relative_path = path.relative_path_from(project.path.dirname)
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end
end
end
ENABLE_OBJECT_USE_OBJC_FROM = {
:ios => Version.new('6'),
:osx => Version.new('10.8'),
:watchos => Version.new('2.0'),
:tvos => Version.new('9.0'),
}
}.freeze
# Returns the compiler flags for the source files of the given specification.
#
......
......@@ -158,12 +158,6 @@ module Pod
support_files_dir + "#{label}.modulemap"
end
# @return [Pathname] the absolute path of the prefix header file.
#
def prefix_header_path
support_files_dir + "#{label}-prefix.pch"
end
# @return [Pathname] the absolute path of the bridge support file.
#
def bridge_support_path
......
......@@ -216,6 +216,12 @@ module Pod
specs.select(&:test_specification?)
end
# @return [Array<Specification>] All of the non test specs within this target.
#
def non_test_specs
specs.reject(&:test_specification?)
end
# @return [Array<Symbol>] All of the test supported types within this target.
#
def supported_test_types
......@@ -396,6 +402,21 @@ module Pod
support_files_dir + "#{test_target_label(test_type)}-frameworks.sh"
end
# @return [Pathname] the absolute path of the prefix header file.
#
def prefix_header_path
support_files_dir + "#{label}-prefix.pch"
end
# @param [Symbol] test_type
# The test type this embed frameworks script path is for.
#
# @return [Pathname] the absolute path of the prefix header file for the given test type.
#
def prefix_header_path_for_test_type(test_type)
support_files_dir + "#{test_target_label(test_type)}-prefix.pch"
end
# @return [Array<String>] The names of the Pods on which this target
# depends.
#
......
......@@ -40,10 +40,6 @@ module Pod
@lib.copy_resources_script_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-resources.sh')
end
it 'returns the absolute path of the prefix header file' do
@lib.prefix_header_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-prefix.pch')
end
it 'returns the absolute path of the bridge support file' do
@lib.bridge_support_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods.bridgesupport')
end
......
......@@ -59,10 +59,6 @@ module Pod
@target.embed_frameworks_script_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-frameworks.sh')
end
it 'returns the absolute path of the prefix header file' do
@target.prefix_header_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods-prefix.pch')
end
it 'returns the absolute path of the bridge support file' do
@target.bridge_support_path.to_s.should.include?('Pods/Target Support Files/Pods/Pods.bridgesupport')
end
......
......@@ -215,6 +215,10 @@ module Pod
@pod_target.build_product_path('$BUILT_PRODUCTS_DIR').should == '$BUILT_PRODUCTS_DIR/BananaLib/libBananaLib.a'
@pod_target.scoped.first.build_product_path('$BUILT_PRODUCTS_DIR').should == '$BUILT_PRODUCTS_DIR/BananaLib-Pods/libBananaLib-Pods.a'
end
it 'returns prefix header path' do
@pod_target.prefix_header_path.to_s.should.include 'Pods/Target Support Files/BananaLib/BananaLib-prefix.pch'
end
end
describe 'Product type dependent helpers' do
......@@ -419,6 +423,10 @@ module Pod
@test_pod_target.embed_frameworks_script_path_for_test_type(:unit).to_s.should.include 'Pods/Target Support Files/CoconutLib/CoconutLib-Unit-Tests-frameworks.sh'
end
it 'returns correct prefix header path for test unit test type' do
@test_pod_target.prefix_header_path_for_test_type(:unit).to_s.should.include 'Pods/Target Support Files/CoconutLib/CoconutLib-Unit-Tests-prefix.pch'
end
it 'returns the correct resource path for test resource bundles' do
fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
fa.stubs(:resource_bundles).returns('TestResourceBundle' => [Pathname.new('Model.xcdatamodeld')])
......
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