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