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
75366ff6
Commit
75366ff6
authored
Jun 21, 2015
by
Boris Bügling
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3676 from CocoaPods/podfile-validator
[Podfile] Validations
parents
78c6f0e6
956d569e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
0 deletions
+164
-0
CHANGELOG.md
CHANGELOG.md
+5
-0
installer.rb
lib/cocoapods/installer.rb
+1
-0
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+10
-0
podfile_validator.rb
lib/cocoapods/installer/podfile_validator.rb
+86
-0
podfile_validator_spec.rb
spec/unit/installer/podfile_validator_spec.rb
+62
-0
No files found.
CHANGELOG.md
View file @
75366ff6
...
@@ -54,6 +54,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -54,6 +54,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
*
Cache globbing in
`PathList`
to speed up
`pod install`
.
*
Cache globbing in
`PathList`
to speed up
`pod install`
.
[
Vincent Isambart
](
https://github.com/vincentisambart
)
[
Vincent Isambart
](
https://github.com/vincentisambart
)
*
CocoaPods will validate your podfile and try to identify problems
and conflicts in how you've specified the dependencies
[
Hugo Tunius
](
https://github.com/k0nserv
)
[
#995
](
https://github.com/CocoaPods/CocoaPods/issues/995
)
##### Bug Fixes
##### Bug Fixes
*
Added recursive support to the public headers of vendored frameworks
*
Added recursive support to the public headers of vendored frameworks
...
...
lib/cocoapods/installer.rb
View file @
75366ff6
...
@@ -34,6 +34,7 @@ module Pod
...
@@ -34,6 +34,7 @@ module Pod
autoload
:PostInstallHooksContext
,
'cocoapods/installer/post_install_hooks_context'
autoload
:PostInstallHooksContext
,
'cocoapods/installer/post_install_hooks_context'
autoload
:PreInstallHooksContext
,
'cocoapods/installer/pre_install_hooks_context'
autoload
:PreInstallHooksContext
,
'cocoapods/installer/pre_install_hooks_context'
autoload
:Migrator
,
'cocoapods/installer/migrator'
autoload
:Migrator
,
'cocoapods/installer/migrator'
autoload
:PodfileValidator
,
'cocoapods/installer/podfile_validator'
autoload
:PodSourceInstaller
,
'cocoapods/installer/pod_source_installer'
autoload
:PodSourceInstaller
,
'cocoapods/installer/pod_source_installer'
autoload
:PodSourcePreparer
,
'cocoapods/installer/pod_source_preparer'
autoload
:PodSourcePreparer
,
'cocoapods/installer/pod_source_preparer'
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
...
...
lib/cocoapods/installer/analyzer.rb
View file @
75366ff6
...
@@ -52,6 +52,7 @@ module Pod
...
@@ -52,6 +52,7 @@ module Pod
# @return [AnalysisResult]
# @return [AnalysisResult]
#
#
def
analyze
(
allow_fetches
=
true
)
def
analyze
(
allow_fetches
=
true
)
validate_podfile!
validate_lockfile_version!
validate_lockfile_version!
@result
=
AnalysisResult
.
new
@result
=
AnalysisResult
.
new
compute_target_platforms
compute_target_platforms
...
@@ -143,6 +144,15 @@ module Pod
...
@@ -143,6 +144,15 @@ module Pod
private
private
def
validate_podfile!
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
unless
validator
.
valid?
raise
Informative
,
validator
.
message
end
end
# @!group Analysis steps
# @!group Analysis steps
# @note The warning about the version of the Lockfile doesn't use the
# @note The warning about the version of the Lockfile doesn't use the
...
...
lib/cocoapods/installer/podfile_validator.rb
0 → 100644
View file @
75366ff6
module
Pod
class
Installer
# Validate the podfile before installing to catch errors and
# problems
#
class
PodfileValidator
# @return [Podfile] The podfile being validated
#
attr_reader
:podfile
# @return [Array<String>] any errors that have occured during the validation
#
attr_reader
:errors
# Initialize a new instance
# @param [Podfile] podfile
# The podfile to validate
#
def
initialize
(
podfile
)
@podfile
=
podfile
@errors
=
[]
@validated
=
false
end
# Validate the podfile
# Errors are added to the errors array
#
def
validate
validate_pod_directives
@validated
=
true
end
# Wether the podfile is valid is not
# NOTE: Will execute `validate` if the podfile
# has not yet been validated
#
def
valid?
validate
unless
@validated
@validated
&&
errors
.
size
==
0
end
# A message describing any errors in the
# validation
#
def
message
errors
.
join
(
"
\n
"
)
end
private
def
add_error
(
error
)
errors
<<
error
end
def
validate_pod_directives
dependencies
=
podfile
.
target_definitions
.
flat_map
do
|
_
,
target
|
target
.
dependencies
end
.
uniq
dependencies
.
each
do
|
dependency
|
validate_conflicting_external_sources!
(
dependency
)
end
end
def
validate_conflicting_external_sources!
(
dependency
)
external_source
=
dependency
.
external_source
return
false
if
external_source
.
nil?
available_downloaders
=
Downloader
.
downloader_class_by_key
.
keys
specified_downloaders
=
external_source
.
select
{
|
key
|
available_downloaders
.
include?
(
key
)
}
if
specified_downloaders
.
size
>
1
add_error
"The dependency `
#{
dependency
.
name
}
` specifies more than one download strategy(
#{
specified_downloaders
.
keys
.
join
(
','
)
}
)."
\
'Only one is allowed'
end
pod_spec_or_path
=
external_source
[
:podspec
].
present?
||
external_source
[
:path
].
present?
if
pod_spec_or_path
&&
specified_downloaders
.
size
>
0
add_error
"The dependency `
#{
dependency
.
name
}
` specifies `podspec` or `path` in combination with other"
\
' download strategies. This is not allowed'
end
end
end
end
end
spec/unit/installer/podfile_validator_spec.rb
0 → 100644
View file @
75366ff6
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Installer
::
PodfileValidator
do
describe
'podspec/path in combination with other download strategies'
do
it
'validates that podspec is not used in combination with other download strategies'
do
podfile
=
Pod
::
Podfile
.
new
do
pod
'JSONKit'
,
:podspec
=>
'https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/JSONKit/1.5pre/JSONKit.podspec.json'
,
:git
=>
'git@github.com:johnezang/JSONKit.git'
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
valid?
.
should
.
be
.
false
validator
.
errors
.
size
.
should
==
1
validator
.
errors
[
0
].
should
.
match
/The dependency `JSONKit` specifies `podspec` or `path`/
end
it
'validates that path is not used in combination with other download strategies'
do
podfile
=
Pod
::
Podfile
.
new
do
pod
'JSONKit'
,
:path
=>
'./JSONKit/1.5pre/JSONKit.podspec.json'
,
:git
=>
'git@github.com:johnezang/JSONKit.git'
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
valid?
.
should
.
be
.
false
validator
.
errors
.
size
.
should
==
1
validator
.
errors
[
0
].
should
.
match
/The dependency `JSONKit` specifies `podspec` or `path`/
end
it
'validates when calling `valid?` before calling `validate`'
do
podfile
=
Pod
::
Podfile
.
new
do
pod
'JSONKit'
,
:path
=>
'./JSONKit/1.5pre/JSONKit.podspec.json'
,
:git
=>
'git@github.com:johnezang/JSONKit.git'
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
valid?
validator
.
valid?
.
should
.
be
.
false
end
end
describe
'multiple download strategies'
do
it
'validates that only one download strategy is specified'
do
podfile
=
Pod
::
Podfile
.
new
do
pod
'JSONKit'
,
:svn
=>
'svn.example.com/JSONKit'
,
:git
=>
'git@github.com:johnezang/JSONKit.git'
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
valid?
.
should
.
be
.
false
validator
.
errors
.
size
.
should
==
1
validator
.
errors
[
0
].
should
.
match
/The dependency `JSONKit` specifies more than one/
end
end
end
end
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