Commit 8fc003dd authored by Fabio Pelosin's avatar Fabio Pelosin

[Podfile] Assign a default deployment target if not given for a platform.

This is a better solution for the previous implementation as it allows
to ignore the deployment target if not specified in a pod.

See #358.
parent cae642fe
...@@ -33,12 +33,6 @@ module Pod ...@@ -33,12 +33,6 @@ module Pod
# Platform.new(:ios) # Platform.new(:ios)
# Platform.new(:ios, '4.3') # Platform.new(:ios, '4.3')
# #
# @overload initialize(name, opts)
# @deprecated Remove after adding a warning to {Podfile} class.
# @param [Symbol] name The name of platform.
# @param [Hash] opts The options to create a platform with.
# @option opts [String, Version] :deployment_target The deployment target.
#
# @overload initialize(platform) # @overload initialize(platform)
# @param [Platform] platform Another {Platform}. # @param [Platform] platform Another {Platform}.
# #
...@@ -51,23 +45,9 @@ module Pod ...@@ -51,23 +45,9 @@ module Pod
if input.is_a? Platform if input.is_a? Platform
@symbolic_name = input.name @symbolic_name = input.name
@deployment_target = input.deployment_target @deployment_target = input.deployment_target
@declared_deployment_target = input.declared_deployment_target
else else
@symbolic_name = input @symbolic_name = input
target = target[:deployment_target] if target.is_a?(Hash) target = target[:deployment_target] if target.is_a?(Hash)
@declared_deployment_target = target
unless target
case @symbolic_name
when :ios
target = '4.3'
when :osx
target = '10.6'
else
target = ''
end
end
@deployment_target = Version.create(target) @deployment_target = Version.create(target)
end end
end end
...@@ -82,10 +62,6 @@ module Pod ...@@ -82,10 +62,6 @@ module Pod
# #
attr_reader :deployment_target attr_reader :deployment_target
# @return [Version] The deployment target declared on initialization.
#
attr_reader :declared_deployment_target
# @param [Platform, Symbol] other The other platform to check. # @param [Platform, Symbol] other The other platform to check.
# #
# @note If a symbol is passed the comparison does not take into account # @note If a symbol is passed the comparison does not take into account
...@@ -109,7 +85,11 @@ module Pod ...@@ -109,7 +85,11 @@ module Pod
# #
def supports?(other) def supports?(other)
other = Platform.new(other) other = Platform.new(other)
if other.deployment_target && deployment_target
(other.name == name) && (other.deployment_target <= deployment_target) (other.name == name) && (other.deployment_target <= deployment_target)
else
other.name == name
end
end end
# @return [String] A string representation including the deployment target. # @return [String] A string representation including the deployment target.
...@@ -121,7 +101,7 @@ module Pod ...@@ -121,7 +101,7 @@ module Pod
when :osx when :osx
s = 'OS X' s = 'OS X'
end end
s << " #{declared_deployment_target}" if declared_deployment_target s << " #{deployment_target}" if deployment_target
s s
end end
...@@ -134,7 +114,7 @@ module Pod ...@@ -134,7 +114,7 @@ module Pod
# @return Whether the platform requires legacy architectures for iOS. # @return Whether the platform requires legacy architectures for iOS.
# #
def requires_legacy_ios_archs? def requires_legacy_ios_archs?
(name == :ios) && (deployment_target < Version.new("4.3")) (name == :ios) && deployment_target && (deployment_target < Version.new("4.3"))
end end
end end
end end
...@@ -173,19 +173,35 @@ module Pod ...@@ -173,19 +173,35 @@ module Pod
end end
# Specifies the platform for which a static library should be build. # Specifies the platform for which a static library should be build.
#
# This can be either `:osx` for Mac OS X applications, or `:ios` for iOS # This can be either `:osx` for Mac OS X applications, or `:ios` for iOS
# applications. # applications.
# #
# For iOS applications, you can set the deployment target by passing a :deployment_target # @param [Symbol] name The name of platform.
# option, e.g: # @param [String, Version] target The optional deployment.
# If not provided a default value according to the platform name will
# be assigned.
#
# @example
# #
# platform :ios, :deployment_target => "4.0" # platform :ios, "4.0"
# platform :ios
# #
# If the deployment target requires it (< 4.3), armv6 will be added to ARCHS. # @note If the deployment target requires it (< 4.3), armv6 will be added
# to ARCHS.
# #
def platform(platform, options={}) def platform(name, target = nil)
@target_definition.platform = Platform.new(platform, options) # Support for deprecated options parameter
target = target[:deployment_target] if target.is_a?(Hash)
unless target
case name
when :ios
target = '4.3'
when :osx
target = '10.6'
end
end
@target_definition.platform = Platform.new(name, target)
end end
# Specifies the Xcode workspace that should contain all the projects. # Specifies the Xcode workspace that should contain all the projects.
......
...@@ -55,10 +55,6 @@ describe Pod::Platform do ...@@ -55,10 +55,6 @@ describe Pod::Platform do
p.deployment_target.should == Pod::Version.new('4.0.0') p.deployment_target.should == Pod::Version.new('4.0.0')
end end
it "provides a default deployment target on initialization" do
p = Pod::Platform.new(:ios)
p.deployment_target.should == Pod::Version.new('4.3')
end
end end
describe "regarding supporting platforms" do describe "regarding supporting platforms" do
......
...@@ -11,6 +11,11 @@ describe "Pod::Podfile" do ...@@ -11,6 +11,11 @@ describe "Pod::Podfile" do
podfile.target_definitions[:default].platform.should == :ios podfile.target_definitions[:default].platform.should == :ios
end end
it "provides a default deployment target if not specified" do
podfile = Pod::Podfile.new { platform :ios }
podfile.target_definitions[:default].platform.deployment_target.should == Pod::Version.new('4.3')
end
it "adds dependencies" do it "adds dependencies" do
podfile = Pod::Podfile.new { dependency 'ASIHTTPRequest'; dependency 'SSZipArchive', '>= 0.1' } podfile = Pod::Podfile.new { dependency 'ASIHTTPRequest'; dependency 'SSZipArchive', '>= 0.1' }
podfile.dependencies.size.should == 2 podfile.dependencies.size.should == 2
......
...@@ -382,7 +382,7 @@ describe "A Pod::Specification subspec" do ...@@ -382,7 +382,7 @@ describe "A Pod::Specification subspec" do
@subspec.supports_platform?(:osx).should.be.false @subspec.supports_platform?(:osx).should.be.false
@subspec.supports_platform?(:ios, '4.0').should.be.true @subspec.supports_platform?(:ios, '4.0').should.be.true
@subspec.supports_platform?(:ios, '5.0').should.be.true @subspec.supports_platform?(:ios, '5.0').should.be.true
@subsubspec.supports_platform?(:ios).should.be.false @subsubspec.supports_platform?(:ios).should.be.true
@subsubspec.supports_platform?(:osx).should.be.false @subsubspec.supports_platform?(:osx).should.be.false
@subsubspec.supports_platform?(:ios, '4.0').should.be.false @subsubspec.supports_platform?(:ios, '4.0').should.be.false
@subsubspec.supports_platform?(:ios, '5.0').should.be.true @subsubspec.supports_platform?(:ios, '5.0').should.be.true
......
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