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
5255b902
Commit
5255b902
authored
Mar 12, 2016
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PodfileValidator] Validate there are no duplicate targets in the Podfile
parent
109d9702
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
podfile_validator.rb
lib/cocoapods/installer/podfile_validator.rb
+11
-0
podfile_validator_spec.rb
spec/unit/installer/podfile_validator_spec.rb
+49
-0
No files found.
lib/cocoapods/installer/podfile_validator.rb
View file @
5255b902
...
@@ -34,6 +34,7 @@ module Pod
...
@@ -34,6 +34,7 @@ module Pod
validate_pod_directives
validate_pod_directives
validate_no_abstract_only_pods!
validate_no_abstract_only_pods!
validate_dependencies_are_present!
validate_dependencies_are_present!
validate_no_duplicate_targets!
@validated
=
true
@validated
=
true
end
end
...
@@ -122,6 +123,16 @@ module Pod
...
@@ -122,6 +123,16 @@ module Pod
add_error
"The dependency `
#{
dep
}
` is not used in any concrete target."
add_error
"The dependency `
#{
dep
}
` is not used in any concrete target."
end
end
end
end
def
validate_no_duplicate_targets!
podfile
.
target_definition_list
.
group_by
{
|
td
|
[
td
.
name
,
td
.
user_project_path
]
}.
each
do
|
(
name
,
project
),
definitions
|
next
unless
definitions
.
size
>
1
error
=
"The target `
#{
name
}
` is declared twice"
error
<<
" for the project `
#{
project
}
`"
if
project
add_error
(
error
<<
'.'
)
end
end
end
end
end
end
end
end
spec/unit/installer/podfile_validator_spec.rb
View file @
5255b902
...
@@ -182,5 +182,54 @@ module Pod
...
@@ -182,5 +182,54 @@ module Pod
validator
.
errors
.
should
.
be
.
empty
validator
.
errors
.
should
.
be
.
empty
end
end
end
end
describe
'duplicated targets'
do
it
'errors when the same target is declared twice'
do
podfile
=
Pod
::
Podfile
.
new
do
pod
'Alamofire'
target
'Target'
target
'Target'
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
not
.
be
.
valid
validator
.
errors
.
should
==
[
'The target `Target` is declared twice.'
]
end
it
'errors when the same target is declared twice when using a custom xcodeproj'
do
podfile
=
Pod
::
Podfile
.
new
do
pod
'Alamofire'
target
'Target'
do
xcodeproj
'Project.xcodeproj'
end
target
'Target'
do
xcodeproj
'Project.xcodeproj'
end
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
not
.
be
.
valid
validator
.
errors
.
should
==
[
'The target `Target` is declared twice for the project `Project.xcodeproj`.'
]
end
it
'does not error when the same target is declared twice for different projects'
do
podfile
=
Pod
::
Podfile
.
new
do
pod
'Alamofire'
target
'Target'
do
xcodeproj
'Project.xcodeproj'
end
target
'Target'
do
xcodeproj
'Project 1.xcodeproj'
end
target
'Target'
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
be
.
valid
end
end
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