Commit e00268b7 authored by Marius Rackwitz's avatar Marius Rackwitz

Merge pull request #2918 from CocoaPods/dont-generate-targets-if-no-source-files

Do not generate targets for Pods without sources
parents c6b6f5f4 87546c3e
...@@ -17,6 +17,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -17,6 +17,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements ##### Enhancements
* Do not generate targets for Pods without sources.
[Boris Bügling](https://github.com/neonichu)
[#2918](https://github.com/CocoaPods/CocoaPods/issues/2918)
* Show the name of the source for each hook that is run in verbose mode. * Show the name of the source for each hook that is run in verbose mode.
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#2639](https://github.com/CocoaPods/CocoaPods/issues/2639) [#2639](https://github.com/CocoaPods/CocoaPods/issues/2639)
......
...@@ -73,6 +73,7 @@ module Pod ...@@ -73,6 +73,7 @@ module Pod
# Add pod static lib to list of libraries that are to be linked with # Add pod static lib to list of libraries that are to be linked with
# the user’s project. # the user’s project.
next unless pod_target.should_build?
@xcconfig.merge!('OTHER_LDFLAGS' => %(-l "#{pod_target.name}")) @xcconfig.merge!('OTHER_LDFLAGS' => %(-l "#{pod_target.name}"))
end end
......
...@@ -435,7 +435,9 @@ module Pod ...@@ -435,7 +435,9 @@ module Pod
pod_targets.sort_by(&:name).each do |pod_target| pod_targets.sort_by(&:name).each do |pod_target|
pod_target.file_accessors.each do |file_accessor| pod_target.file_accessors.each do |file_accessor|
file_accessor.spec_consumer.frameworks.each do |framework| file_accessor.spec_consumer.frameworks.each do |framework|
pod_target.native_target.add_system_framework(framework) if pod_target.should_build?
pod_target.native_target.add_system_framework(framework)
end
end end
end end
end end
...@@ -445,6 +447,7 @@ module Pod ...@@ -445,6 +447,7 @@ module Pod
def set_target_dependencies def set_target_dependencies
aggregate_targets.each do |aggregate_target| aggregate_targets.each do |aggregate_target|
aggregate_target.pod_targets.each do |pod_target| aggregate_target.pod_targets.each do |pod_target|
next unless pod_target.should_build?
aggregate_target.native_target.add_dependency(pod_target.native_target) aggregate_target.native_target.add_dependency(pod_target.native_target)
pod_target.dependencies.each do |dep| pod_target.dependencies.each do |dep|
......
...@@ -9,6 +9,8 @@ module Pod ...@@ -9,6 +9,8 @@ module Pod
# @return [void] # @return [void]
# #
def install! def install!
return unless target.should_build?
UI.message "- Installing target `#{target.name}` #{target.platform}" do UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target add_target
create_support_files_dir create_support_files_dir
......
...@@ -34,6 +34,14 @@ module Pod ...@@ -34,6 +34,14 @@ module Pod
# #
attr_accessor :file_accessors attr_accessor :file_accessors
# @return [Bool] Whether or not this target should be build.
#
# A target should not be build if it has no source files.
#
def should_build?
!file_accessors.flat_map(&:source_files).empty?
end
# @return [Array<Specification::Consumer>] the specification consumers for # @return [Array<Specification::Consumer>] the specification consumers for
# the target. # the target.
# #
......
...@@ -17,6 +17,8 @@ module Pod ...@@ -17,6 +17,8 @@ module Pod
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
@pod_target.stubs(:spec_consumers).returns([@consumer]) @pod_target.stubs(:spec_consumers).returns([@consumer])
file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@pod_target.stubs(:file_accessors).returns([file_accessor])
@target.pod_targets = [@pod_target] @target.pod_targets = [@pod_target]
@generator = AggregateXCConfig.new(@target, 'Release') @generator = AggregateXCConfig.new(@target, 'Release')
end end
...@@ -91,6 +93,29 @@ module Pod ...@@ -91,6 +93,29 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe "if a pod target does not contain source files" do
before do
@pod_target.file_accessors.first.stubs(:source_files).returns([])
@xcconfig = @generator.generate
end
it 'does not link with the aggregate integration library target' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-l"Pods-BananaLib"'
end
it 'does link with vendored frameworks' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-framework "Bananalib"'
end
it 'does link with vendored libraries' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-l"Bananalib"'
end
end
#-----------------------------------------------------------------------#
before do before do
@path = temporary_directory + 'sample.xcconfig' @path = temporary_directory + 'sample.xcconfig'
@generator.save_as(@path) @generator.save_as(@path)
......
...@@ -151,6 +151,14 @@ module Pod ...@@ -151,6 +151,14 @@ module Pod
dummy.read.should.include?('@interface PodsDummy_Pods') dummy.read.should.include?('@interface PodsDummy_Pods')
end end
#--------------------------------------------------------------------------------#
it 'does not create a target if the specification does not define source files' do
@pod_target.file_accessors.first.stubs(:source_files).returns([])
@installer.install!
@project.targets.should == []
end
#--------------------------------------------------------------------------------# #--------------------------------------------------------------------------------#
describe 'concerning compiler flags' do describe 'concerning compiler flags' do
before do before do
......
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