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
# Platform.new(:ios)
# 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)
# @param [Platform] platform Another {Platform}.
#
......@@ -51,23 +45,9 @@ module Pod
if input.is_a? Platform
@symbolic_name = input.name
@deployment_target = input.deployment_target
@declared_deployment_target = input.declared_deployment_target
else
@symbolic_name = input
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)
end
end
......@@ -82,10 +62,6 @@ module Pod
#
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.
#
# @note If a symbol is passed the comparison does not take into account
......@@ -109,7 +85,11 @@ module Pod
#
def supports?(other)
other = Platform.new(other)
if other.deployment_target && deployment_target
(other.name == name) && (other.deployment_target <= deployment_target)
else
other.name == name
end
end
# @return [String] A string representation including the deployment target.
......@@ -121,7 +101,7 @@ module Pod
when :osx
s = 'OS X'
end
s << " #{declared_deployment_target}" if declared_deployment_target
s << " #{deployment_target}" if deployment_target
s
end
......@@ -134,7 +114,7 @@ module Pod
# @return Whether the platform requires legacy architectures for iOS.
#
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
......@@ -173,19 +173,35 @@ module Pod
end
# 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
# applications.
#
# For iOS applications, you can set the deployment target by passing a :deployment_target
# option, e.g:
# @param [Symbol] name The name of platform.
# @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={})
@target_definition.platform = Platform.new(platform, options)
def platform(name, target = nil)
# 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
# Specifies the Xcode workspace that should contain all the projects.
......
......@@ -55,10 +55,6 @@ describe Pod::Platform do
p.deployment_target.should == Pod::Version.new('4.0.0')
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
describe "regarding supporting platforms" do
......
......@@ -11,6 +11,11 @@ describe "Pod::Podfile" do
podfile.target_definitions[:default].platform.should == :ios
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
podfile = Pod::Podfile.new { dependency 'ASIHTTPRequest'; dependency 'SSZipArchive', '>= 0.1' }
podfile.dependencies.size.should == 2
......
......@@ -382,7 +382,7 @@ describe "A Pod::Specification subspec" do
@subspec.supports_platform?(:osx).should.be.false
@subspec.supports_platform?(:ios, '4.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?(:ios, '4.0').should.be.false
@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