Commit 142b70bd authored by Anand Biligiri's avatar Anand Biligiri

sub-specs to share code between app and extensions

 A "host target" (Eg: iOS app target) aggregates all "pod targets"
 for an "embeddable target" (Eg: extension). When app and extension
 use parts of a pod via sub-spec, the "pod target" names are unique,
 but module_name is specified only at the root_spec. The target
 validation should consider only unique module_names while detecting
 duplicate frameworks.
parent b9e665e1
...@@ -39,6 +39,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -39,6 +39,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[David Airapetyan](https://github.com/davidair) [David Airapetyan](https://github.com/davidair)
[#4887](https://github.com/CocoaPods/CocoaPods/issues/4887) [#4887](https://github.com/CocoaPods/CocoaPods/issues/4887)
* Select unique module_name(s) across host target's and embedded targets' pod targets
[Anand Biligiri](https://github.com/abiligiri)
[#6711](https://github.com/CocoaPods/CocoaPods/issues/6711)
## 1.3.0.beta.2 (2017-06-22) ## 1.3.0.beta.2 (2017-06-22)
##### Enhancements ##### Enhancements
......
...@@ -47,7 +47,7 @@ module Pod ...@@ -47,7 +47,7 @@ module Pod
file_accessors = pod_targets.flat_map(&:file_accessors) file_accessors = pod_targets.flat_map(&:file_accessors)
frameworks = file_accessors.flat_map(&:vendored_frameworks).uniq.map(&:basename) frameworks = file_accessors.flat_map(&:vendored_frameworks).uniq.map(&:basename)
frameworks += pod_targets.select { |pt| pt.should_build? && pt.requires_frameworks? }.map(&:product_module_name) frameworks += pod_targets.select { |pt| pt.should_build? && pt.requires_frameworks? }.map(&:product_module_name).uniq
verify_no_duplicate_names(frameworks, aggregate_target.label, 'frameworks') verify_no_duplicate_names(frameworks, aggregate_target.label, 'frameworks')
libraries = file_accessors.flat_map(&:vendored_libraries).uniq.map(&:basename) libraries = file_accessors.flat_map(&:vendored_libraries).uniq.map(&:basename)
......
...@@ -17,9 +17,9 @@ module Pod ...@@ -17,9 +17,9 @@ module Pod
# @return [AnalysisResult] # @return [AnalysisResult]
# #
def create_validator(sandbox, podfile, lockfile) def create_validator(sandbox, podfile, lockfile, integrate_targets = false)
installation_options = Installer::InstallationOptions.new.tap do |options| installation_options = Installer::InstallationOptions.new.tap do |options|
options.integrate_targets = false options.integrate_targets = integrate_targets
end end
@analyzer = Analyzer.new(config.sandbox, podfile, lockfile).tap do |analyzer| @analyzer = Analyzer.new(config.sandbox, podfile, lockfile).tap do |analyzer|
...@@ -35,6 +35,10 @@ module Pod ...@@ -35,6 +35,10 @@ module Pod
end end
describe '#verify_no_duplicate_framework_and_library_names' do describe '#verify_no_duplicate_framework_and_library_names' do
before do
SpecHelper.create_sample_app_copy_from_fixture('Sample Extensions Project')
end
it 'detects duplicate library names' do it 'detects duplicate library names' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('a/libBananalib.a')]) Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('a/libBananalib.a')])
Pod::Specification.any_instance.stubs(:dependencies).returns([]) Pod::Specification.any_instance.stubs(:dependencies).returns([])
...@@ -92,6 +96,29 @@ module Pod ...@@ -92,6 +96,29 @@ module Pod
@validator = create_validator(config.sandbox, podfile, lockfile) @validator = create_validator(config.sandbox, podfile, lockfile)
should.not.raise(Informative) { @validator.validate! } should.not.raise(Informative) { @validator.validate! }
end end
it 'including multiple subspecs from the same pod in a target does not result in duplicate frameworks' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Pod::Podfile.new do
platform :ios, '9.3'
project 'Sample Extensions Project/Sample Extensions Project'
use_frameworks!
target 'Sample Extensions Project' do
pod 'matryoshka/Foo', :path => (fixture_path + 'matryoshka').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
end
target 'Today Extension' do
pod 'matryoshka/Foo', :path => (fixture_path + 'matryoshka').to_s
end
end
lockfile = generate_lockfile
@validator = create_validator(config.sandbox, podfile, lockfile, true)
should.not.raise(Informative) { @validator.validate! }
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
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