Commit 16e9da30 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'issue_1449_duplicate_prefix_header_contents' of…

Merge branch 'issue_1449_duplicate_prefix_header_contents' of https://github.com/luisdelarosa/CocoaPods into luisdelarosa-issue_1449_duplicate_prefix_header_contents

* 'issue_1449_duplicate_prefix_header_contents' of https://github.com/luisdelarosa/CocoaPods:
  Addressed comments from @irrationalfab: - simplified collection of unique prefix_header_contents - reduced sub specs in spec from 4 to 2 Removed inline documentation and added @notes and @todos. Added entry to Changelog.
  Fix issue #1449 by collecting the prefix_header_contents and uniq-ing them.
  Add integration test for issue #1449.
  Added two tests for issue #1449 - however both are passing at the unit level so I suspect that the issue will need to be tested at the integration test level.

Conflicts:
	CHANGELOG.md
parents d579fe46 67d7efcb
...@@ -60,6 +60,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -60,6 +60,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Robert Zuber](https://github.com/z00b) [Robert Zuber](https://github.com/z00b)
[#1617](https://github.com/CocoaPods/CocoaPods/issues/1617) [#1617](https://github.com/CocoaPods/CocoaPods/issues/1617)
* Generated prefix header file will now have unique prefix_header_contents for
Pods with subspecs.
[Luis de la Rosa](https://github.com/luisdelarosa)
[#1449](https://github.com/CocoaPods/CocoaPods/issues/1449)
* The linter will now check the reachability of the homepage of Podspecs during * The linter will now check the reachability of the homepage of Podspecs during
a full lint. a full lint.
[Richard Lee](https://github.com/dlackty) [Richard Lee](https://github.com/dlackty)
......
...@@ -40,9 +40,12 @@ module Pod ...@@ -40,9 +40,12 @@ module Pod
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h` # added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported. # is imported.
# #
# @note Only unique prefix_header_contents are added to the prefix header.
#
# @return [String] # @return [String]
# #
# @todo Subspecs can specify prefix header information too. # @todo Subspecs can specify prefix header information too.
# @todo Check to see if we have a similar duplication issue with file_accessor.prefix_header.
# #
def generate def generate
result = "#ifdef __OBJC__\n" result = "#ifdef __OBJC__\n"
...@@ -53,12 +56,18 @@ module Pod ...@@ -53,12 +56,18 @@ module Pod
result << %|\n#import "#{import}"| result << %|\n#import "#{import}"|
end end
file_accessors.each do |file_accessor| unique_prefix_header_contents = file_accessors.collect do |file_accessor|
file_accessor.spec_consumer.prefix_header_contents
end.compact.uniq
result << "\n" result << "\n"
if prefix_header_contents = file_accessor.spec_consumer.prefix_header_contents
unique_prefix_header_contents.each do |prefix_header_contents|
result << prefix_header_contents result << prefix_header_contents
result << "\n" result << "\n"
end end
file_accessors.each do |file_accessor|
if prefix_header = file_accessor.prefix_header if prefix_header = file_accessor.prefix_header
result << Pathname(prefix_header).read result << Pathname(prefix_header).read
end end
......
...@@ -331,6 +331,10 @@ describe "Integration" do ...@@ -331,6 +331,10 @@ describe "Integration" do
check "install --no-repo-update", "install_subspecs" check "install --no-repo-update", "install_subspecs"
end end
describe "Installs a Pod with subspecs and does not duplicate the prefix header" do
check "install --no-repo-update", "install_subspecs_no_duplicate_prefix"
end
describe "Installs a Pod with a local source" do describe "Installs a Pod with a local source" do
check "install --no-repo-update", "install_local_source" check "install --no-repo-update", "install_local_source"
end end
......
...@@ -21,6 +21,43 @@ module Pod ...@@ -21,6 +21,43 @@ module Pod
EOS EOS
end end
# @note Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
it "does not duplicate the contents of the specification's prefix header when a subspec is declared" do
@spec.prefix_header_contents = '#import "BlocksKit.h"'
@spec.prefix_header_file = nil
@spec.subspec 'UI' do |subspec|
subspec.source_files = 'Source/UI/*.{h,m}'
end
@gen.generate.should == <<-EOS.strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "BlocksKit.h"
EOS
end
# @note Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
it "does not duplicate the contents of the specification's prefix header when a subspec is declared multiple times" do
@spec.prefix_header_contents = '#import "BlocksKit.h"'
@spec.prefix_header_file = nil
@spec.subspec 'UI' do |su|
su.source_files = 'Source/UI/*.{h,m}'
end
@spec.subspec 'Helpers' do |sh|
sh.source_files = 'Source/Helpers/*.{h,m}'
end
@gen.generate.should == <<-EOS.strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "BlocksKit.h"
EOS
end
it "includes the contents of the specification's prefix header file" do it "includes the contents of the specification's prefix header file" do
@gen.generate.should == <<-EOS.strip_heredoc @gen.generate.should == <<-EOS.strip_heredoc
#ifdef __OBJC__ #ifdef __OBJC__
......
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