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

Merge pull request #6484 from dnkoutso/handle-edgecase

Do not crash when attempting to install pod with no supported targets
parents a951feef 1731ca9c
...@@ -18,6 +18,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -18,6 +18,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes ##### Bug Fixes
* Do not crash when attempting to install pod with no supported targets.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6465](https://github.com/CocoaPods/CocoaPods/issues/6465)
* Correctly handle `OTHER_LDFLAGS` for targets with inherit search paths and source pods. * Correctly handle `OTHER_LDFLAGS` for targets with inherit search paths and source pods.
[Justin Martin](https://github.com/justinseanmartin) [Justin Martin](https://github.com/justinseanmartin)
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
......
...@@ -338,6 +338,8 @@ module Pod ...@@ -338,6 +338,8 @@ module Pod
end end
end end
raise Informative, "Could not install '#{pod_name}' pod. There is no target that supports it." if specs_by_platform.empty?
@pod_installers ||= [] @pod_installers ||= []
pod_installer = PodSourceInstaller.new(sandbox, specs_by_platform, :can_cache => installation_options.clean?) pod_installer = PodSourceInstaller.new(sandbox, specs_by_platform, :can_cache => installation_options.clean?)
@pod_installers << pod_installer @pod_installers << pod_installer
......
...@@ -4,6 +4,8 @@ module Pod ...@@ -4,6 +4,8 @@ module Pod
class Installer class Installer
class Analyzer class Analyzer
class TargetInspector class TargetInspector
PLATFORM_INFO_URL = 'https://guides.cocoapods.org/syntax/podfile.html#platform'.freeze
# @return [TargetDefinition] the target definition to inspect # @return [TargetDefinition] the target definition to inspect
# #
attr_accessor :target_definition attr_accessor :target_definition
...@@ -159,6 +161,10 @@ module Pod ...@@ -159,6 +161,10 @@ module Pod
"Unable to determine the platform for the `#{target_definition.name}` target." "Unable to determine the platform for the `#{target_definition.name}` target."
end end
UI.warn "Automatically assigning platform #{name} with version #{deployment_target} " \
"on target #{target_definition.name} because no platform was specified. " \
"Please specify a platform for this target in your Podfile. See `#{PLATFORM_INFO_URL}`."
target_definition.set_platform(name, deployment_target) target_definition.set_platform(name, deployment_target)
Platform.new(name, deployment_target) Platform.new(name, deployment_target)
end end
......
Subproject commit e62f3157268e9d2fe634dfab2560c89013d89240 Subproject commit 29e64c27eff470779877e8ffc24fdaf707f261a8
...@@ -232,6 +232,9 @@ module Pod ...@@ -232,6 +232,9 @@ module Pod
target_inspector = TargetInspector.new(target_definition, config.installation_root) target_inspector = TargetInspector.new(target_definition, config.installation_root)
platforms = target_inspector.send(:compute_platform, user_targets) platforms = target_inspector.send(:compute_platform, user_targets)
platforms.should == Platform.new(:ios, '4.0') platforms.should == Platform.new(:ios, '4.0')
UI.warnings.should.include 'Automatically assigning platform ios with version 4.0 on target default because no ' \
'platform was specified. Please specify a platform for this target in your Podfile. ' \
'See `https://guides.cocoapods.org/syntax/podfile.html#platform`.'
end end
it 'uses the lowest deployment target of the user targets if inferring the platform' do it 'uses the lowest deployment target of the user targets if inferring the platform' do
......
...@@ -540,6 +540,16 @@ module Pod ...@@ -540,6 +540,16 @@ module Pod
UI.output.should.include 'was 1.0' UI.output.should.include 'was 1.0'
end end
it 'raises when it attempts to install pod source with no target supporting it' do
spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = PodTarget.new([spec], [fixture_target_definition], config.sandbox)
pod_target.stubs(:platform).returns(:ios)
@installer.stubs(:pod_targets).returns([pod_target])
should.raise Informative do
@installer.send(:create_pod_installer, 'RandomPod')
end.message.should.include 'Could not install \'RandomPod\' pod. There is no target that supports it.'
end
#--------------------------------------# #--------------------------------------#
describe '#clean' do describe '#clean' 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