Commit 0f562c02 authored by Orta's avatar Orta

Merge pull request #3407 from CocoaPods/seg-platform-mismatch-warning

[Analyzer] Only warn when there is a minimum deployment target mismatch
parents 6a456add d341177f
...@@ -17,6 +17,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -17,6 +17,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
`pod repo list`. `pod repo list`.
[Kyle Fuller](https://github.com/kylef) [Kyle Fuller](https://github.com/kylef)
* Only show a warning when there is a minimum deployment target mismatch
between target and spec, instead of throwing a hard error.
[Samuel Giddins](https://github.com/segiddins)
[#1241](https://github.com/CocoaPods/CocoaPods/issues/1241)
##### Bug Fixes ##### Bug Fixes
* Do not pass code-sign arguments to xcodebuild when linting OS X targets. * Do not pass code-sign arguments to xcodebuild when linting OS X targets.
......
...@@ -55,7 +55,7 @@ module Pod ...@@ -55,7 +55,7 @@ module Pod
store_existing_checkout_options store_existing_checkout_options
fetch_external_sources if allow_fetches fetch_external_sources if allow_fetches
@result.specs_by_target = resolve_dependencies @result.specs_by_target = validate_platforms(resolve_dependencies)
@result.specifications = generate_specifications @result.specifications = generate_specifications
@result.targets = generate_targets @result.targets = generate_targets
@result.sandbox_state = generate_sandbox_state @result.sandbox_state = generate_sandbox_state
...@@ -431,6 +431,26 @@ module Pod ...@@ -431,6 +431,26 @@ module Pod
specs_by_target specs_by_target
end end
# Warns for any specification that is incompatible with its target.
#
# @param [Hash{TargetDefinition => Array<Spec>}] specs_by_target
# the specifications grouped by target.
#
# @return [Hash{TargetDefinition => Array<Spec>}] the specifications
# grouped by target.
#
def validate_platforms(specs_by_target)
specs_by_target.each do |target, specs|
specs.each do |spec|
unless spec.available_platforms.any? { |p| target.platform.supports?(p) }
UI.warn "The platform of the target `#{target.name}` " \
"(#{target.platform}) may not be compatible with `#{spec}` which has " \
"a minimum requirement of #{spec.available_platforms.join(' - ')}."
end
end
end
end
# Returns the list of all the resolved the resolved specifications. # Returns the list of all the resolved the resolved specifications.
# #
# @return [Array<Specification>] the list of the specifications. # @return [Array<Specification>] the list of the specifications.
......
...@@ -355,16 +355,13 @@ module Pod ...@@ -355,16 +355,13 @@ module Pod
# #
# @raise If the specification is not supported by the target. # @raise If the specification is not supported by the target.
# #
# @todo This step is not specific to the resolution process and should be
# performed later in the analysis.
#
# @return [void] # @return [void]
# #
def validate_platform(spec, target) def validate_platform(spec, target)
unless spec.available_platforms.any? { |p| target.platform.supports?(p) } unless spec.available_platforms.any? { |p| target.platform.to_sym == p.to_sym }
raise Informative, "The platform of the target `#{target.name}` " \ raise Informative, "The platform of the target `#{target.name}` " \
"(#{target.platform}) is not compatible with `#{spec}` which has " \ "(#{target.platform}) is not compatible with `#{spec}`, which does " \
"a minimum requirement of #{spec.available_platforms.join(' - ')}." "not support `#{target.platform.name}`."
end end
end end
......
...@@ -271,6 +271,12 @@ module Pod ...@@ -271,6 +271,12 @@ module Pod
] ]
end end
it 'warns once any of the dependencies does not match the platform of its podfile target' do
Specification.any_instance.stubs(:available_platforms).returns([Platform.new(:ios, '999')])
@analyzer.analyze
UI.warnings.should.match(/platform .* may not be compatible/)
end
xit 'removes the specifications of the changed pods to prevent confusion in the resolution process' do xit 'removes the specifications of the changed pods to prevent confusion in the resolution process' do
@analyzer.allow_pre_downloads = true @analyzer.allow_pre_downloads = true
podspec = @analyzer.sandbox.root + 'Local Podspecs/JSONKit.podspec' podspec = @analyzer.sandbox.root + 'Local Podspecs/JSONKit.podspec'
......
...@@ -169,12 +169,6 @@ module Pod ...@@ -169,12 +169,6 @@ module Pod
].sort_by(&:name) ].sort_by(&:name)
end end
it 'raises once any of the dependencies does not match the platform of its podfile target' do
Specification.any_instance.stubs(:available_platforms).returns([Platform.new(:ios, '999')])
e = lambda { @resolver.resolve }.should.raise Informative
e.message.should.match(/platform .* not compatible/)
end
it 'raises when a resolved dependency has a platform incompatibility' do it 'raises when a resolved dependency has a platform incompatibility' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :osx, '10.7' platform :osx, '10.7'
......
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