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
9b11b799
Commit
9b11b799
authored
Dec 26, 2015
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move empty podfile validation to the podfile validator
parent
92a04dca
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
25 deletions
+39
-25
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+1
-0
podfile_validator.rb
lib/cocoapods/installer/podfile_validator.rb
+28
-0
user_project_integrator.rb
lib/cocoapods/installer/user_project_integrator.rb
+0
-18
podfile_validator_spec.rb
spec/unit/installer/podfile_validator_spec.rb
+10
-0
user_project_integrator_spec.rb
spec/unit/installer/user_project_integrator_spec.rb
+0
-7
No files found.
lib/cocoapods/installer/analyzer.rb
View file @
9b11b799
...
...
@@ -160,6 +160,7 @@ module Pod
unless
validator
.
valid?
raise
Informative
,
validator
.
message
end
validator
.
warnings
.
uniq
.
each
{
|
w
|
UI
.
warn
(
w
)
}
end
# @!group Analysis steps
...
...
lib/cocoapods/installer/podfile_validator.rb
View file @
9b11b799
...
...
@@ -12,6 +12,11 @@ module Pod
#
attr_reader
:errors
# @return [Array<String>] any warnings that have occured during the validation
#
attr_reader
:warnings
# Initialize a new instance
# @param [Podfile] podfile
# The podfile to validate
...
...
@@ -19,6 +24,7 @@ module Pod
def
initialize
(
podfile
)
@podfile
=
podfile
@errors
=
[]
@warnings
=
[]
@validated
=
false
end
...
...
@@ -28,6 +34,7 @@ module Pod
def
validate
validate_pod_directives
validate_no_abstract_only_pods!
validate_dependencies_are_present!
@validated
=
true
end
...
...
@@ -55,6 +62,10 @@ module Pod
errors
<<
error
end
def
add_warning
(
warning
)
warnings
<<
warning
end
def
validate_pod_directives
dependencies
=
podfile
.
target_definitions
.
flat_map
do
|
_
,
target
|
target
.
dependencies
...
...
@@ -83,6 +94,23 @@ module Pod
end
end
# Warns the user if the podfile is empty.
#
# @note The workspace is created in any case and all the user projects
# are added to it, however the projects are not integrated as
# there is no way to discern between target definitions which are
# empty and target definitions which just serve the purpose to
# wrap other ones. This is not an issue because empty target
# definitions generate empty libraries.
#
# @return [void]
#
def
validate_dependencies_are_present!
if
podfile
.
target_definitions
.
values
.
all?
(
&
:empty?
)
add_warning
'The Podfile does not contain any dependencies.'
end
end
def
validate_no_abstract_only_pods!
abstract_pods
=
->
(
target_definition
)
do
if
!
target_definition
.
abstract?
||
!
target_definition
.
children
.
empty?
...
...
lib/cocoapods/installer/user_project_integrator.rb
View file @
9b11b799
...
...
@@ -61,7 +61,6 @@ module Pod
def
integrate!
create_workspace
integrate_user_targets
warn_about_empty_podfile
warn_about_xcconfig_overrides
save_projects
end
...
...
@@ -152,23 +151,6 @@ module Pod
end
end
# Warns the user if the podfile is empty.
#
# @note The workspace is created in any case and all the user projects
# are added to it, however the projects are not integrated as
# there is no way to discern between target definitions which are
# empty and target definitions which just serve the purpose to
# wrap other ones. This is not an issue because empty target
# definitions generate empty libraries.
#
# @return [void]
#
def
warn_about_empty_podfile
if
podfile
.
target_definitions
.
values
.
all?
(
&
:empty?
)
UI
.
warn
'[!] The Podfile does not contain any dependencies.'
end
end
IGNORED_KEYS
=
%w(CODE_SIGN_IDENTITY)
.
freeze
INHERITED_FLAGS
=
%w($(inherited) ${inherited})
.
freeze
...
...
spec/unit/installer/podfile_validator_spec.rb
View file @
9b11b799
...
...
@@ -62,5 +62,15 @@ module Pod
validator
.
errors
[
0
].
should
.
match
/The dependency `JSONKit` specifies more than one/
end
end
it
'warns if the podfile does not contain any dependency'
do
podfile
=
Pod
::
Podfile
.
new
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
be
.
valid
validator
.
errors
.
should
.
be
.
empty
validator
.
warnings
.
should
==
[
'The Podfile does not contain any dependencies.'
]
end
end
end
spec/unit/installer/user_project_integrator_spec.rb
View file @
9b11b799
...
...
@@ -51,13 +51,6 @@ module Pod
@integrator
.
integrate!
end
it
'warns if the podfile does not contain any dependency'
do
@podfile
=
Pod
::
Podfile
.
new
@integrator
.
stubs
(
:podfile
).
returns
(
@podfile
)
@integrator
.
integrate!
UI
.
warnings
.
should
.
include?
(
'The Podfile does not contain any dependencies'
)
end
it
'deintegrates targets that are not associated with the podfile'
do
additional_project
=
Xcodeproj
::
Project
.
new
(
'Project.xcodeproj'
)
Deintegrator
.
any_instance
.
expects
(
:deintegrate_target
).
with
additional_project
.
new_target
(
:application
,
'Other App'
,
:ios
)
...
...
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