Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
fdcbd63f
Commit
fdcbd63f
authored
May 04, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #241 from CocoaPods/deployment-target-check
[#212] Check for deployment target
parents
da1c8a0d
1b6372c9
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
63 deletions
+118
-63
spec.rb
lib/cocoapods/command/spec.rb
+10
-8
platform.rb
lib/cocoapods/platform.rb
+11
-10
resolver.rb
lib/cocoapods/resolver.rb
+2
-2
specification.rb
lib/cocoapods/specification.rb
+12
-9
platform_spec.rb
spec/unit/platform_spec.rb
+57
-17
resolver_spec.rb
spec/unit/resolver_spec.rb
+5
-17
specification_spec.rb
spec/unit/specification_spec.rb
+21
-0
No files found.
lib/cocoapods/command/spec.rb
View file @
fdcbd63f
...
...
@@ -532,16 +532,17 @@ Pod::Spec.new do |s|
s.description = 'An optional longer description of
#{
data
[
:name
]
}
.'
# If this Pod runs only on iOS or OS X, then specify that with one of
# these, or none if it runs on both platforms.
# If the pod runs on both plafroms but presents different deployment
# targets, source files, etc. create two different pods: `
#{
data
[
:name
]
}
-iOS'
# and `
#{
data
[
:name
]
}
-OSX'.
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target.
#
# s.platform = :ios, '5.0'
# s.platform = :ios
# s.platform = :ios, { :deployment_target => "5.0" }
# s.platform = :osx
# s.platform = :osx, { :deployment_target => "10.7" }
# If this Pod runs on boths platforms, then specify the deployment
# targets.
#
# s.ios.deployment_target = '5.0'
# s.osx.deployment_target = '10.7'
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script.
...
...
@@ -589,6 +590,7 @@ Pod::Spec.new do |s|
#
# s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
# ――― INFO ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
end
SPEC
end
...
...
lib/cocoapods/platform.rb
View file @
fdcbd63f
...
...
@@ -8,22 +8,29 @@ module Pod
new
:osx
end
attr_reader
:options
attr_reader
:options
,
:deployment_target
def
initialize
(
symbolic_name
,
options
=
{}
)
def
initialize
(
symbolic_name
,
deployment_target
=
nil
)
@symbolic_name
=
symbolic_name
@options
=
options
if
deployment_target
version
=
deployment_target
.
is_a?
(
Hash
)
?
deployment_target
[:
deployment_target
]
:
deployment_target
# backwards compatibility from 0.6
@deployment_target
=
Pod
::
Version
.
create
(
version
)
end
end
def
name
@symbolic_name
end
def
deployment_target
=
(
version
)
@deployment_target
=
Pod
::
Version
.
create
(
version
)
end
def
==
(
other_platform_or_symbolic_name
)
if
other_platform_or_symbolic_name
.
is_a?
(
Symbol
)
@symbolic_name
==
other_platform_or_symbolic_name
else
self
==
(
other_platform_or_symbolic_name
.
name
)
self
.
name
==
(
other_platform_or_symbolic_name
.
name
)
&&
self
.
deployment_target
==
other_platform_or_symbolic_name
.
deployment_target
end
end
...
...
@@ -51,12 +58,6 @@ module Pod
name
.
nil?
end
def
deployment_target
if
(
options
&&
opt
=
options
[
:deployment_target
])
Pod
::
Version
.
new
(
opt
)
end
end
def
requires_legacy_ios_archs?
return
unless
deployment_target
(
name
==
:ios
)
&&
(
deployment_target
<
Pod
::
Version
.
new
(
"4.3"
))
...
...
lib/cocoapods/resolver.rb
View file @
fdcbd63f
...
...
@@ -84,8 +84,8 @@ module Pod
end
def
validate_platform!
(
spec
,
target
)
unless
target
.
platform
.
support?
(
spec
.
platform
)
raise
Informative
,
"[!] The platform
required by the target `
#{
target
.
name
}
' `
#{
target
.
platform
}
' does not match that of
#{
spec
}
`
#{
spec
.
platform
}
'
"
.
red
unless
spec
.
platforms
.
any?
{
|
platform
|
target
.
platform
.
support?
(
platform
)
}
raise
Informative
,
"[!] The platform
of the target `
#{
target
.
name
}
' (
#{
target
.
platform
}
) is not compatible with `
#{
spec
}
' which has a minimun requirement of
#{
spec
.
platforms
.
join
(
' - '
)
}
.
"
.
red
end
end
end
...
...
lib/cocoapods/specification.rb
View file @
fdcbd63f
...
...
@@ -34,6 +34,7 @@ module Pod
@define_for_platforms
=
[
:osx
,
:ios
]
@clean_paths
,
@subspecs
=
[],
[]
@dependencies
,
@source_files
,
@resources
=
{
:ios
=>
[],
:osx
=>
[]
},
{
:ios
=>
[],
:osx
=>
[]
},
{
:ios
=>
[],
:osx
=>
[]
}
@deployment_target
=
{}
@platform
=
Platform
.
new
(
nil
)
@xcconfig
=
{
:ios
=>
Xcodeproj
::
Config
.
new
,
:osx
=>
Xcodeproj
::
Config
.
new
}
@compiler_flags
=
{
:ios
=>
''
,
:osx
=>
''
}
...
...
@@ -114,17 +115,14 @@ module Pod
end
def
platform
=
(
platform
)
if
platform
.
class
==
Array
name
=
platform
[
0
]
options
=
platform
[
1
]
else
name
=
platform
options
=
nil
end
@platform
=
Platform
.
new
(
name
,
options
)
@platform
=
Platform
.
new
(
*
platform
)
end
attr_reader
:platform
def
platforms
@platform
.
nil?
?
@define_for_platforms
.
map
{
|
platfrom
|
Platform
.
new
(
platfrom
,
@deployment_target
[
platfrom
])
}
:
[
platform
]
end
def
requires_arc
=
(
requires_arc
)
self
.
compiler_flags
=
'-fobjc-arc'
if
requires_arc
@requires_arc
=
requires_arc
...
...
@@ -157,7 +155,7 @@ module Pod
@specification
,
@platform
=
specification
,
platform
end
%w{ source_files= resource= resources= xcconfig= framework= frameworks= library= libraries= compiler_flags= dependency }
.
each
do
|
method
|
%w{ source_files= resource= resources= xcconfig= framework= frameworks= library= libraries= compiler_flags= dep
loyment_target= dep
endency }
.
each
do
|
method
|
define_method
(
method
)
do
|
args
|
@specification
.
_on_platform
(
@platform
)
do
@specification
.
send
(
method
,
args
)
...
...
@@ -181,6 +179,11 @@ module Pod
end
attr_reader
:source_files
def
deployment_target
=
(
version
)
raise
Informative
,
"The deployment target must be defined per platform like s.ios.deployment_target = '5.0'"
unless
@define_for_platforms
.
count
==
1
@deployment_target
[
@define_for_platforms
.
first
]
=
version
end
def
resources
=
(
patterns
)
@define_for_platforms
.
each
do
|
platform
|
@resources
[
platform
]
=
pattern_list
(
patterns
)
...
...
spec/unit/platform_spec.rb
View file @
fdcbd63f
...
...
@@ -18,6 +18,11 @@ describe Pod::Platform do
@platform
.
should
==
Pod
::
Platform
.
new
(
:ios
)
end
it
"can be compared for equality with another platform with the same symbolic name and the same deployment target"
do
@platform
.
should
.
not
==
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
Pod
::
Platform
.
new
(
:ios
,
'4.0'
).
should
==
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
end
it
"can be compared for equality with a matching symbolic name (backwards compatibility reasons)"
do
@platform
.
should
==
:ios
end
...
...
@@ -26,28 +31,31 @@ describe Pod::Platform do
@platform
.
to_s
.
should
==
"iOS"
Pod
::
Platform
.
new
(
:osx
).
to_s
.
should
==
'OS X'
Pod
::
Platform
.
new
(
nil
).
to_s
.
should
==
"iOS - OS X"
Pod
::
Platform
.
new
(
:ios
,
{
:deployment_target
=>
'5.0.0'
}).
to_s
.
should
==
'iOS 5.0.0'
Pod
::
Platform
.
new
(
:osx
,
{
:deployment_target
=>
'10.7'
}).
to_s
.
should
==
'OS X 10.7'
end
it
"correctly indicates if it supports another platfrom"
do
ios4
=
Pod
::
Platform
.
new
(
:ios
,
{
:deployment_target
=>
'4.0.0'
})
ios5
=
Pod
::
Platform
.
new
(
:ios
,
{
:deployment_target
=>
'5.0.0'
})
ios5
.
should
.
support?
(
ios4
)
ios4
.
should
.
not
.
support?
(
ios5
)
osx6
=
Pod
::
Platform
.
new
(
:osx
,
{
:deployment_target
=>
'10.6'
})
osx7
=
Pod
::
Platform
.
new
(
:osx
,
{
:deployment_target
=>
'10.7'
})
osx7
.
should
.
support?
(
osx6
)
osx6
.
should
.
not
.
support?
(
osx7
)
both
=
Pod
::
Platform
.
new
(
nil
)
both
.
should
.
support?
(
ios4
)
both
.
should
.
support?
(
osx6
)
both
.
should
.
support?
(
nil
)
Pod
::
Platform
.
new
(
:ios
,
'5.0.0'
).
to_s
.
should
==
'iOS 5.0.0'
Pod
::
Platform
.
new
(
:osx
,
'10.7'
).
to_s
.
should
==
'OS X 10.7'
end
it
"uses it's name as it's symbold version"
do
@platform
.
to_sym
.
should
==
:ios
end
it
"allows to specify the deployment target on initialization"
do
p
=
Pod
::
Platform
.
new
(
:ios
,
'4.0.0'
)
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
end
it
"allows to specify the deployment target in a hash on initialization (backwards compatibility from 0.6)"
do
p
=
Pod
::
Platform
.
new
(
:ios
,
{
:deployment_target
=>
'4.0.0'
})
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
end
it
"allows to specify the deployment target after initialization"
do
p
=
Pod
::
Platform
.
new
(
:ios
,
'4.0.0'
)
p
.
deployment_target
=
'4.0.0'
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
p
.
deployment_target
=
Pod
::
Version
.
new
(
'4.0.0'
)
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
end
end
describe
"Pod::Platform with a nil value"
do
...
...
@@ -59,3 +67,35 @@ describe "Pod::Platform with a nil value" do
@platform
.
should
.
be
.
nil
end
end
describe
"Pod::Platform#support?"
do
it
"supports another platform is with the same operating system"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p2
=
Pod
::
Platform
.
new
(
:ios
)
p1
.
should
.
support?
(
p2
)
p1
=
Pod
::
Platform
.
new
(
:osx
)
p2
=
Pod
::
Platform
.
new
(
:osx
)
p1
.
should
.
support?
(
p2
)
end
it
"supports a nil platform"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p1
.
should
.
support?
(
nil
)
end
it
"supports a platform with a lower or equal deployment_target"
do
p1
=
Pod
::
Platform
.
new
(
:ios
,
'5.0'
)
p2
=
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
p1
.
should
.
support?
(
p1
)
p1
.
should
.
support?
(
p2
)
p2
.
should
.
not
.
support?
(
p1
)
end
it
"supports a platform regardless of the deployment_target if one of the two does not specify it"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p2
=
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
p1
.
should
.
support?
(
p2
)
p2
.
should
.
support?
(
p1
)
end
end
spec/unit/resolver_spec.rb
View file @
fdcbd63f
...
...
@@ -39,7 +39,7 @@ describe "Pod::Resolver" do
lambda
{
@resolver
.
resolve
}.
should
.
not
.
raise
end
it
"raises once any of the dependencies does not match the platform of
the root spec (Podfile)
"
do
it
"raises once any of the dependencies does not match the platform of
its podfile target
"
do
set
=
Pod
::
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/ASIHTTPRequest'
)
@resolver
.
cached_sets
[
'ASIHTTPRequest'
]
=
set
...
...
@@ -59,27 +59,15 @@ describe "Pod::Resolver" do
lambda
{
@resolver
.
resolve
}.
should
.
raise
Pod
::
Informative
end
it
"
does not raise if all of the dependencies have a deployment target equal or lower of the root spec (Podfile)
"
do
it
"
raises once any of the dependencies does not have a deployment_target compatible with its podfile target
"
do
set
=
Pod
::
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/ASIHTTPRequest'
)
@resolver
.
cached_sets
[
'ASIHTTPRequest'
]
=
set
@podfile
.
platform
:ios
,
"4.0"
def
set
.
stub_platform
=
(
platform
);
@stubbed_platform
=
platform
;
end
def
set
.
specification
;
spec
=
super
;
spec
.
platform
=
@stubbed_platform
;
spec
;
end
@podfile
.
platform
:ios
,
{
:deployment_target
=>
"4.0.0"
}
set
.
stub_platform
=
:ios
,
{
:deployment_target
=>
"4.0.0"
}
Pod
::
Specification
.
any_instance
.
stubs
(
:platforms
).
returns
([
Pod
::
Platform
.
new
(
:ios
,
'4.0'
),
Pod
::
Platform
.
new
(
:osx
,
'10.7'
)
])
lambda
{
@resolver
.
resolve
}.
should
.
not
.
raise
end
it
"raises once any of the dependencies requires a higher deployment target of the root spec (Podfile)"
do
set
=
Pod
::
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/ASIHTTPRequest'
)
@resolver
.
cached_sets
[
'ASIHTTPRequest'
]
=
set
def
set
.
stub_platform
=
(
platform
);
@stubbed_platform
=
platform
;
end
def
set
.
specification
;
spec
=
super
;
spec
.
platform
=
@stubbed_platform
;
spec
;
end
@podfile
.
platform
:ios
,
{
:deployment_target
=>
"4.0.0"
}
set
.
stub_platform
=
:ios
,
{
:deployment_target
=>
"5.0.0"
}
Pod
::
Specification
.
any_instance
.
stubs
(
:platforms
).
returns
([
Pod
::
Platform
.
new
(
:ios
,
'5.0'
),
Pod
::
Platform
.
new
(
:osx
,
'10.7'
)
])
lambda
{
@resolver
.
resolve
}.
should
.
raise
Pod
::
Informative
end
...
...
spec/unit/specification_spec.rb
View file @
fdcbd63f
...
...
@@ -154,6 +154,19 @@ describe "A Pod::Specification, in general," do
@spec
.
platform
.
should
==
:ios
end
it
"returns the platform and the deployment target"
do
@spec
.
platform
=
:ios
,
'4.0'
@spec
.
platform
.
should
==
:ios
@spec
.
platform
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0'
)
end
it
"returns the platfroms for which the pod is supported"
do
@spec
.
platform
=
:ios
,
'4.0'
@spec
.
platforms
.
count
.
should
==
1
@spec
.
platforms
.
first
.
should
==
:ios
@spec
.
platforms
.
first
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0'
)
end
it
"returns the license of the Pod"
do
@spec
.
license
=
{
:type
=>
'MIT'
,
...
...
@@ -364,6 +377,8 @@ describe "A Pod::Specification, concerning its attributes that support different
s
.
ios
.
dependency
'JSONKit'
s
.
osx
.
dependency
'SSZipArchive'
s
.
ios
.
deployment_target
=
'4.0'
end
end
...
...
@@ -382,6 +397,12 @@ describe "A Pod::Specification, concerning its attributes that support different
}
end
it
"returns the list of the supported platfroms and deployment targets"
do
@spec
.
platforms
.
count
.
should
==
2
@spec
.
platforms
.
should
.
include?
Pod
::
Platform
.
new
(
:osx
)
@spec
.
platforms
.
should
.
include?
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
end
it
"returns the same list of compiler flags for each platform"
do
@spec
.
compiler_flags
.
should
==
{
:ios
=>
' -Wdeprecated-implementations -fobjc-arc'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment